2012-05-06 9 views
0

Activityに由来するカスタムダイアログがあり、RelativeLayoutを使用します。すべての位置付けとプロパティはXMLファイルで処理され、コードでは処理されません。私はレイアウトを正確に私はそれが欲しい方法が、ダイアログの項目のいくつかの長さのため、情報のいくつかの行が次の行に折り返します。このような場合、ダイアログの「閉じる」ボタンが誰かのように見えるという点を除いて、これは問題ではありません。RelativeLayoutのStrange Buttonの動作

これは、微細なボタンを示しエミュレータからのスクリーンショットですが、それはダイアログの右側に直面して突き合わせていないので、私が説明テキストの右側にいくつかのパディングをしたい:

Good button, but needs right margin

これを見て、レイアウトファイルにandroid:layout_marginRight="5dp"を追加しました。私の余白を得ることを望んでいました。私はラップを取っていますが、ボタンは正しくありません。説明が現在行を折り返しているため、ダイアログの高さは変更されません。

Good wrapping, but button squished

は、ここに私の完全なレイアウトXMLです。 RelativeLayoutを初めて使用したのですが、うまくいけば、これは私が見落としているシンプルなものです。

<?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"> 
     <ImageView 
       android:id="@+id/achievement_icon" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentTop="true" 
       android:layout_alignParentLeft="true" 
       android:layout_marginLeft="7dp" 
       android:contentDescription="@string/achievement_icon" /> 
     <TextView 
       android:id="@+id/achievement_name" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="5dp" 
       android:layout_marginRight="5dp" 
       android:textColor="#ffffff" 
       android:textStyle="bold" 
       android:layout_toRightOf="@+id/achievement_icon" /> 
     <TextView 
       android:id="@+id/achievement_gamerscore" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:textColor="#ffffff" 
       android:textStyle="bold" 
       android:layout_marginLeft="5dp" 
       android:layout_below="@+id/achievement_name" 
       android:layout_toRightOf="@+id/achievement_icon" /> 
     <TextView 
       android:id="@+id/achievement_description" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="7dp" 
       android:layout_marginRight="5dp" 
       android:layout_alignLeft="@+id/achievement_icon" 
       android:layout_below="@+id/achievement_icon" /> 
     <TextView 
       android:id="@+id/achievement_earned" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="7dp" 
       android:layout_marginRight="5dp" 
       android:layout_alignLeft="@+id/achievement_description" 
       android:layout_below="@+id/achievement_description" /> 
     <Button 
       android:id="@+id/cancel" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="7dp" 
       android:layout_centerHorizontal="true" 
       android:text="@string/button_close" 
       android:layout_below="@+id/achievement_earned" /> 
    </RelativeLayout> 

答えて

0

問題は、ボタンのスペースが足りないことです。ボタン用のスペースを確保するために

1)あなたは多分、右上のボタンを移動し、Xなどのそれを表示することができます。

2)あなたは説明のTextViewのサイズを制限し、(scrollviewにもScrollViewを必要とせずにこれを行うためのクリーンな方法をのTextViewを囲むことにより、垂直方向にスクロールするように設定しますが、あなたが私のドリフトを得ることができる。

3.)ボタンの高さを小さくします。

また、アプリの電話機が解像度/密度の異なる電話機でどのように表示されるかを気にしています。ですから、UIを設計するときはこれに注意してください。私が言いたいの

例は次のとおりです。

<ScrollView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:scrollbars="vertical" 
    android:fillViewport="true"> 

    <TextView 
      android:id="@+id/achievement_description" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="7dp" 
      android:layout_marginRight="5dp" 
      android:layout_alignLeft="@+id/achievement_icon" 
      android:layout_below="@+id/achievement_icon" /> 

</ScrollView> 

あなたが特定の値の代わりに、ラッピング内容に「achievement_description」のTextViewの高さを制限する必要がありますが。

関連する問題