2011-07-05 1 views
7

画像を任意の画面の一番下に設定する場合は、相対レイアウトでandroid:layout_alignParentBottom="true"を使用できます。しかし、何らかの理由で私はLinearLayoutを使用する必要があります。画面には他のビュー(ボタン、画像ボタン、リストビュー)もあります。私は画面の下に画像を配置したい。どのような状況であっても、ユーザーはこの画像ビューを画面の下部で見ることができます。 LinearLayoutのalignParentBottom="true"プロパティの取得方法folowingサンプルxmlを参照してください。私はexample1.xmlを使用していますが、私はexample2.xmlのことを見て、ファイルLinearLayoutのalignParentBottom = "true"プロパティを実現する方法

example1.xml

enter image description here

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <TextView 
     android:id="@+id/textview1" 
     android:layout_width="fill_parent" 
     android:layout_height="40dip" 
     android:background="#ffffff" 
     android:textColor="#000000" 
     android:text="I am sunil" 
     android:gravity="bottom"/> 

</LinearLayout> 

example2.xml

< 

?xml version="1.0" encoding="utf-8"?> 

    <RelativeLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 
     <TextView 
      android:id="@+id/textview1" 
      android:layout_width="fill_parent" 
      android:layout_height="40dip" 
      android:background="#ffffff" 
      android:textColor="#000000" 
      android:text="I am sunil" 
      android:layout_alignParentBottom="true"/> 

    </RelativeLayout> 

たいおかげで

答えて

0

gravity="bottom"LinearLayoutに使用できます。 LinearLayout代わりのTextViewため

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:gravity="bottom"> 
    <TextView 
     android:id="@+id/textview1" 
     android:layout_width="fill_parent" 
     android:layout_height="40dip" 
     android:background="#ffffff" 
     android:textColor="#000000" 
     android:text="I am sunil" 
     android:gravity="bottom"/> 

</LinearLayout> 

使用gravity="bottom":ここではより多くの情報についてGravityプロパティについては

look here

はこれを試してみてください、サンプルコードです。

+0

に追加私は=「ボトム」重力を使用していたが、私はrelativelayout –

+0

にalignParentBottom =「true」をに取得していますと、私は同じ効果を得ることはありませんでしたがとしての私の答え –

+0

をチェック私はそのレイアウトで1つのイメージだけではないことを述べました。ギャラリービュー、リストビューもあります –

1

あなたがギャラリービューとリストビューの両方を持っていると仮定すると、それらのいずれかに重みを追加することができます。つまり、できるだけ大きくなるでしょう。複数のビューにウェイトを与えると、余分なスペースを比例して共有します。例えば

、あなたのギャラリーやリストビューandroid:layout_weight="1"

関連する問題