2011-10-24 6 views
0

私は、より小さな画面をスクロール可能にするためにscrollViewで囲まれたlinearLayoutを持っています。線形レイアウトでは、私は3つのチャイルドも持っています。異なるスクリーンサイズの線画アウト

これは問題なく動作しています。しかし、私はまた、より大きな画面をサポートしたい。現時点では、画面の下部に大きな画面スペースが残っています。私はボタン(ナビゲーションバー)を常に底にしたいと思っています。大画面(高さ)の場合は、画面の上部に大きな画面でより多くのスペースを埋める空のビューを追加したいと思います。

どうすれば実現できますか?私は体重の属性でたくさん試してみましたが、うまくいきませんでした。ここで

レイアウト:

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:background="#8db9f6" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <LinearLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:orientation="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:background="#8db9f6"> 
     <LinearLayout 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:orientation="horizontal" 
      android:layout_marginTop="8dp" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"> 
      <TextView 
       android:text="test" 
       android:id="@+id/test" 
       android:paddingLeft="10dp" 
       android:textStyle="bold" 
       android:textSize="20dp" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content"> 
      </TextView> 
      <View 
       android:layout_width="wrap_content" 
       android:layout_height="0dip" 
       android:layout_weight="1"/> 
      <ImageButton 
       android:id="@+id/btnName" 
       android:scaleType="center" 
       android:layout_width="60dp" 
       android:layout_height="48dp" 
       android:src="@android:drawable/ic_menu_edit"> 
      </ImageButton> 
     </LinearLayout> 
     <EditText 
      android:id="@+id/edittest" 
      android:editable="false" 
      android:hint="@string/test" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"> 
     </EditText> 
     <TextView 
      android:text="@string/optionalText" 
      android:id="@+id/test1" 
      android:paddingLeft="10dp" 
      android:textSize="12dp" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"> 
     </TextView> 
     <TextView 
      android:id="@+id/space" 
      android:layout_width="fill_parent" 
      android:layout_marginTop="4dp" 
      android:layout_height="3sp" 
      android:background="#333142"> 
     </TextView> 
     <LinearLayout 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:orientation="horizontal" 
      android:layout_marginTop="5dp" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"> 
      <TextView 
       android:text="TEST TESt" 
       android:id="@+id/test2" 
       android:paddingLeft="10dp" 
       android:layout_marginTop="5dp" 
       android:textStyle="bold" 
       android:textSize="20dp" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content"> 
      </TextView> 
      <View 
       android:layout_width="wrap_content" 
       android:layout_height="0dip" 
       android:layout_weight="1"/> 
      <ProgressBar 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:visibility="gone" 
       android:id="@+id/progressbar"/> 
      <ImageButton 
       android:id="@+id/btnPicture" 
       android:scaleType="center" 
       android:layout_width="60dp" 
       android:layout_height="48dp" 
       android:src="@android:drawable/ic_menu_edit"> 
      </ImageButton> 
     </LinearLayout> 
     <FrameLayout 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:orientation="horizontal" 
      android:background="#ffffff" 
      android:layout_gravity="center" 
      android:layout_width="fill_parent" 
      android:layout_height="150dip"> 
      <ImageView 
       android:id="@+id/test3" 
       android:layout_width="400dip" 
       android:layout_height="150dip" 
       android:layout_gravity="center" 
       android:scaleType="fitCenter" 
       android:src="@drawable/test1"/> 
      <TextView 
       android:id="@+id/text" 
       android:layout_gravity="bottom" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:textSize="8dp" 
       android:text="test test"/> 
     </FrameLayout> 
     <LinearLayout 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:orientation="horizontal" 
      android:layout_gravity="bottom" 
      android:layout_marginTop="3dp" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"> 
      <Button 
       android:id="@+id/scaleMinus" 
       android:textSize="14dp" 
       android:layout_weight="1" 
       android:layout_gravity="bottom" 
       android:layout_width="fill_parent" 
       android:layout_height="40dp" 
       android:text="@string/zoomOut"/> 
      <Button 
       android:id="@+id/scalePlus" 
       android:textSize="14dp" 
       android:layout_weight="1" 
       android:layout_gravity="bottom" 
       android:layout_width="fill_parent" 
       android:layout_height="40dp" 
       android:text="@string/zoomIn"/> 
     </LinearLayout> 
     <TextView 
      android:id="@+id/balken" 
      android:layout_width="fill_parent" 
      android:layout_marginTop="4dp" 
      android:layout_height="3sp" 
      android:background="#333142"> 
     </TextView> 
     <LinearLayout 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:orientation="horizontal" 
      android:layout_marginTop="5dp" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"> 
      <TextView 
       android:text="test test" 
       android:id="@+id/test3" 
       android:paddingLeft="10dp" 
       android:textStyle="bold" 
       android:textSize="20dp" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content"> 
      </TextView> 
      <View 
       android:layout_width="wrap_content" 
       android:layout_height="0dip" 
       android:layout_weight="1"/> 
      <EditText 
       android:id="@+id/test4" 
       android:editable="false" 
       android:layout_width="100dp" 
       android:layout_height="wrap_content"> 
      </EditText> 
      <TextView 
       android:text="test" 
       android:id="@+id/mtest4" 
       android:paddingLeft="10dp" 
       android:textStyle="bold" 
       android:textSize="20dp" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content"> 
      </TextView> 
      <View 
       android:layout_width="wrap_content" 
       android:layout_height="0dip" 
       android:layout_weight="1"/> 
      <ImageButton 
       android:id="@+id/test5" 
       android:scaleType="center" 
       android:layout_width="60dp" 
       android:layout_height="48dp" 
       android:src="@android:drawable/ic_menu_edit"> 
      </ImageButton> 
     </LinearLayout> 
     <TextView 
      android:id="@+id/balken" 
      android:layout_width="fill_parent" 
      android:layout_marginTop="4dp" 
      android:layout_height="3sp" 
      android:background="#333142"> 
     </TextView> 
     <LinearLayout 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:orientation="horizontal" 
      android:layout_gravity="bottom" 
      android:background="#000000" 
      android:paddingTop="5dp" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"> 
      <Button 
       android:id="@+id/save" 
       android:textSize="18dp" 
       android:layout_weight="1" 
       android:layout_gravity="bottom" 
       android:layout_width="fill_parent" 
       android:layout_height="60dp" 
       android:text="@string/save"/> 
      <Button 
       android:id="@+id/cancel" 
       android:textSize="18dp" 
       android:layout_weight="1" 
       android:layout_gravity="bottom" 
       android:layout_width="fill_parent" 
       android:layout_height="60dp" 
       android:text="@string/abort"/> 
     </LinearLayout> 
    </LinearLayout> 
</ScrollView> 
+0

レイアウトでfill_parentを使用しようとしましたか? layout.xmlを投稿して、どのように見えるかを確認してください。 –

+0

はいfill_parentを設定しました。私はレイアウトを投稿します。 – tobias

答えて

2

レイアウト全体を相対レイアウトで囲みます。相対的なレイアウトをルート要素として使用し、ボタンを含む線形レイアウトをlayout_alignParentBottom = "true"に設定し、ScrollViewをlayout_alignParentTop = "true"に設定します。

ボタンとScrollViewを含むLinearLayoutは、RelativeLayoutの直接の子である必要があります。

<RelativeLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
     <LinearLayout <-- containing the layout minus the buttons 
       android:id="@+id/SV" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_alignParentTop="true"> 
      <The Rest Of The Layout> 
     </LinearLayout> 
     <LinearLayout 
       android:id="@+id/LLButtons" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_alignParentBottom="true"> 
      <Buttons> 
      </LinearLayout> 
</ScrollView> 

ボタンを常に画面の下部に配置する場合は、alignParentBottomを使用します。ボタンを常にスクロールビューの一番下にしたい場合alignBelow = "@ id/SV"

+0

Thx。しかし、ScrollViewの開始はありますか? – tobias

+0

ok thx、これはいいです。しかし、今はスペースがボタンの上にあります。私は画面の上にそれをしたい。 – tobias

+0

レイアウトを画面の下部に固定し、上部に空白を入れたいですか?問題ない。 Buttons = alignParentBottom = true&残りのレイアウトのLLはalignAbove = "@ id/LLButtons" – Phobos

0

android:layout_height="wrap_content"あなたの内のLinearLayoutでは役立つはず 'fill_parent' にそれを変更し、ここにあなたの悩みです。一般に、階層ビューアを使用してこのようなレイアウトの問題のトラブルシューティングを行うことができます。

+0

私は3つの内部線形レイアウトを持っています。私はそれらのすべてのために高さのfill_parentを使用する必要がありますか? – tobias

関連する問題