2012-01-24 15 views
0

私はカスタムダイアログを追加したいが、私が望むように私は、XMLを作成する問題を抱えている...ここで カスタムダイアログは、XML

は私が想像して何:

[IMAGE] [TEXT]

[ SCROLLABLETEXT]

[BUTTON] [BUTTON] [BUTTON]

そして、私の現在のxml:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/LinearLayout1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="1" 
    android:orientation="vertical" > 

    <LinearLayout 
     android:id="@+id/linearLayout2" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 

     <ImageView 
      android:id="@+id/imgMentor" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="10dp" 
      android:layout_marginRight="10dp" 
      android:src="@drawable/changelogicon" /> 

     <TextView 
      android:id="@+id/tvSubject" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="--" 
      android:textColor="#FFF" 
      android:textSize="20px" /> 
    </LinearLayout> 

    <ScrollView 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/layout_root" 
     android:layout_width="fill_parent" 
     android:layout_height="match_parent" 
     android:padding="10dp" > 

     <TextView 
      android:id="@+id/tvExplanation" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="7dip" 
      android:text="--" 
      android:textColor="#FFF" /> 
    </ScrollView> 

    <LinearLayout 
    android:id="@+id/linearLayout2" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="1" 
    android:baselineAligned="true" > 


    <Button 
     android:id="@+id/button1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="Button" /> 


    <Button 
     android:id="@+id/button2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="Button" /> 


    <Button 
     android:id="@+id/button3" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="Button" /> 

</LinearLayout> 

</LinearLayout> 

画像、テキストや見栄えのスクロール可能なテキストが、中央にテキストが長すぎる場合やスクロール可能になり、私のボタンがなくなっている。..

私が間違って何をしたのですか? 私の解決策:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/RelativeLayout1" 
    android:layout_width="fill_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <ImageView 
     android:id="@+id/imgIcon" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:layout_marginLeft="10dp" 
     android:layout_marginRight="10dp" 
     android:src="@drawable/changelogicon" /> 

    <TextView 
     android:id="@+id/tvSubject" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignBottom="@+id/imgIcon" 
     android:layout_marginBottom="15dp" 
     android:layout_toRightOf="@+id/imgIcon" 
     android:text="--" 
     android:textColor="#FFF" 
     android:textSize="20px" /> 

    <ScrollView 
     android:id="@+id/layout_root" 
     android:layout_width="fill_parent" 
     android:layout_height="match_parent" 
     android:layout_above="@+id/button1" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@+id/imgIcon" 
     android:layout_marginTop="20dp" > 

     <TextView 
      android:id="@+id/tvExplanation" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="7dip" 
      android:text="--" 
      android:textColor="#FFF" /> 
    </ScrollView> 

    <Button 
     android:id="@+id/button1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:text="Button" /> 

    <Button 
     android:id="@+id/button2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_centerHorizontal="true" 
     android:text="Button" /> 

    <Button 
     android:id="@+id/button3" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentRight="true" 
     android:text="Button" /> 

</RelativeLayout> 
+0

メインの線形レイアウトの外にスクロールビューを配置しようとしましたか? – Hiral

答えて

1

使用RelativeLayoutではなく、あなたのビュー階層の最上位要素としてLinearLayout

EDIT

LinearLayoutは、この種の「中間を満たす」シナリオをうまく処理できません。

RelativeLayoutを使用すると、ボタンをテキストの下端に合わせることができます。テキスト/イメージは上端に合わせてから、ScrollViewをテキスト/イメージの下とボタンの上に合わせて調整します。

詳しくは"Hello RelativeLayout"チュートリアルをご覧ください。

あなたの受け入れ率を上げると、より多くの人があなたの質問に答える可能性が高くなります。

+0

完璧、ありがとう! :) – Prexx

関連する問題