2011-07-05 6 views
0

私はアンドロイドでカスタム対話を設計していますでは正しく表示されないようViewは、この目的のために、私はxmlファイルを設計し、アンドロイドレイアウト

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:background="@color/item_bg_color" 
    android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal"> 

    <TextView android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/custom_dialog_text" 
    android:textColor="#000000" 
    android:textSize="14dip" 
    android:typeface="serif" 
    android:singleLine="false" 
    android:text="You are not authorized to use this application." 
    android:layout_marginTop="10dip"/> 

    <Button android:id="@+id/custom_button_ok" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Ok" 
    android:layout_below="@+id/custom_dialog_text" 
    android:layout_toRightOf="@+id/custom_dialog_text"/> 


</RelativeLayout> 

問題:私は最後にボタンを表示したい

(右)、Textviewのテキストは複数の行になければなりません(複数の文字を表示する必要がある場合)。しかし、私がこのレイアウトを使用しているとき、ボタンはどこにも表示されません。

LinearLayoutとTableLayoutも使用していますが、どちらの場合でもボタンは少ししか表示されません。どこが間違っていますか? layout_alignParentRight、アンドロイド:ボタンの

答えて

1

基本的には、右に揃えるされるボタンを伝えたいですそれが必要とするすべてのスペースを取り、残りのスペースをTextViewに渡します。これを行うには、ボタンとしてandroid:layout_layout_alignParentRight="true"、TextViewにandroid:layout_toLeftOf="@id/custom_button_ok"を指定します。注文を心配!

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:background="@color/item_bg_color" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal"> 
    <Button android:id="@+id/custom_button_ok" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Ok" 
    android:layout_layout_alignParentRight="true" /> 

    <TextView android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/custom_dialog_text" 
    android:textColor="#000000" 
    android:textSize="14dip" 
    android:typeface="serif" 
    android:singleLine="false" 
    android:text="You are not authorized to use this application." 
    android:layout_marginTop="10dip" 
    android:layout_toLeftOf="@id/custom_button_ok" 
    /> 
</RelativeLayout> 
0

属性アンドロイド追加layout_belowを、彼らはこれをdoinのあなた

0

試みを助ける..

<TextView android:layout_width="100dip" 
    android:layout_height="wrap_content" 
    android:id="@+id/custom_dialog_text" 
    android:textColor="#000000" 
    android:textSize="14dip" 
    android:typeface="serif" 
    android:singleLine="false" 
    android:text="You are not authorized to use this application." 
    android:layout_marginTop="10dip"/> 
0

layout_belwとlayout_rightofプロパティは、テキストview.Justに同じIDに設定されているuは下

0

にボタンの重力を設定することができlayout_below.Alsoを使用するあなたの答えは、コード

<?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="wrap_content" 
    android:orientation="horizontal" android:weightSum="1.0"> 
    <RelativeLayout android:layout_height="wrap_content" 
     android:layout_width="0dp" android:layout_weight="0.85"> 
     <TextView android:layout_width="fill_parent" 
      android:layout_height="wrap_content" android:id="@+id/custom_dialog_text" 
      android:textColor="#FFFFFF" android:textSize="14dip" 
      android:typeface="serif" android:singleLine="false" 
      android:text="You are not authorized to use zdsaddsad this application." 
      android:layout_marginTop="10dip" /> 
    </RelativeLayout> 
    <RelativeLayout android:layout_height="wrap_content" 
     android:layout_width="0dp" android:layout_weight="0.15"> 
     <Button android:id="@+id/custom_button_ok" 
      android:layout_width="wrap_content" android:layout_height="wrap_content" 
      android:text="Ok" /> 
    </RelativeLayout> 

</LinearLayout> 
+0

下回ってみてください。私のために働いていますが、レイアウトの深さを見ましたか?この2つのビューだけの良いデザインですか? –

+0

重量合計のコンセプトを使用した場合は、それを使用したように画面を壊すことは決してあなたのデザインでは決してありません。あなたは直接テキストビューとワイト・サム・コンセプト – Nikhil

+0

にボタンを与えて、この答えがうまく働いていればそれをアップヴォートすることができます。 – Nikhil

関連する問題