2012-04-03 7 views
1

を取る作る:私がやりたいのは何AndroidのRelativeLayoutは、編集テキストは、私は以下のレイアウト持っているすべてのスペース

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="@drawable/aussie_bg_big" > 

<ImageView 
    android:id="@+id/titleImage" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_centerHorizontal="true" 
    android:contentDescription="@null" 
    android:src="@drawable/aussie_title_small" /> 

<ImageView 
    android:id="@+id/clearButtonOutput" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_above="@+id/titleImage" 
    android:layout_alignParentRight="true" 
    android:contentDescription="@null" 
    android:src="@drawable/aussie_clear" /> 

<EditText 
    android:id="@+id/OutputText" 
    android:layout_width="fill_parent" 
    android:layout_height="100dp" 
    android:layout_above="@+id/clearButtonOutput" 
    android:layout_alignParentLeft="true" 
    android:background="@drawable/textbox" 
    android:ems="10" 
    android:gravity="top" 
    android:inputType="textMultiLine" 
    android:textColor="#ffffff" /> 

<ImageView 
    android:id="@+id/translateButton" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_above="@+id/OutputText" 
    android:layout_centerHorizontal="true" 
    android:clickable="true" 
    android:contentDescription="@null" 
    android:src="@drawable/translatebuttonselector" /> 

<ImageView 
    android:id="@+id/ClearButton" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_above="@+id/translateButton" 
    android:layout_alignParentRight="true" 
    android:contentDescription="@null" 
    android:src="@drawable/aussie_clear" /> 

<EditText 
    android:id="@+id/InputText" 
    android:layout_width="fill_parent" 
    android:layout_height="100dp" 
    android:layout_above="@+id/ClearButton" 
    android:layout_alignParentLeft="true" 
    android:background="@drawable/textbox" 
    android:ems="10" 
    android:gravity="top" 
    android:inputType="textMultiLine" 
    android:singleLine="false" 
    android:textColor="#ffffff" /> 

されています:

- >"imageBottom"をキープいつでも活動の底面の画像ビューを水平に中心に

- >すべての回での活動の中心に"imageCenter" ImageViewのをキープ、は水平にを中心に。

- >右に整列imageCenterの上方に配置されてのinputTextのEditText以下"imageBelowInputText" ImageViewのを保管してください。

- >右に整列imageCenterimageBottomとの間に位置しているのOutputTextのEditText以下"imageBelowOutputText" ImageViewのを保管してください。

これまでのところうまくいきましたが、私はedittextビューが残りのスペースをすべて占有するようにしたいと思います。それぞれの編集テキストのサイズをdpiでハードコードしているので、小さな、普通の、大型の、x-largeスクリーン用のさまざまなバージョンのレイアウトを提供してくれました。しかし、いくつかのレイアウトでは、それはやはり少し間違って見えてしまいます(ミスアラインメント)。だからこそ私は最初にImageViewsを配置し、2つのEditTextが残りのスペースをすべてEQUALLY(重要)にするソリューションを探しています。

これまでのところ、私は100%正しい解を考えることができませんでした。あなたは私を助けることができます?ありがとう!

+0

あなたが何をしたいの絵画的表現が –

+0

があなたのxmlレイアウトをリファクタリング...素晴らしいものになるように設定さlayout_weight。レイアウトにどこにも表示されないIDが表示されます( 'clearButtonOutput'?!?!)。 – Luksprog

+0

申し訳ありません。レイアウトを再投稿しました。 –

答えて

0

お知らせ2 edittextsは「0dp」へのlayout_heightセットを持っており、「1」 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="fill_parent" 
    android:paddingTop="15dp" 
    android:orientation="vertical" > 

    <EditText 
     android:id="@+id/editText1" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" /> 

    <Button 
     android:id="@+id/button1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="right" 
     android:text="Clear" /> 

    <Button 
     android:id="@+id/button2" 
     android:layout_width="wrap_content" 
     android:layout_height="100dp" 
     android:layout_gravity="center" 
     android:text="Bear" /> 

    <EditText 
     android:id="@+id/editText1" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" /> 

    <Button 
     android:id="@+id/button2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="right" 
     android:text="Clear" /> 

    <Button 
     android:id="@+id/button2" 
     android:layout_width="wrap_content" 
     android:layout_height="100dp" 
     android:layout_gravity="center" 
     android:text="Speaking Aussie" /> 

</LinearLayout> 
+0

これは私が達成したいことに近いです。私は写真を共有することができましたが、あなたの例をさらに説明する方が良いと思います:3番目のテキストボックスを削除してください。中央ボタン1は水平および垂直に配置します。テキストボックス1はbutton1の上にあり、textbox2はbutton1の下にあります。 Button2はtextbox2の下にあります。 Textbox1と2のサイズは同じで残りのすべてのスペースを占有します(サイズが固定された2つのボタンの左)。それが私が達成したいものです。 –

+0

これはいかがですか? –

+0

クール、それを試してみましょう。しかし、一番上の編集テキストはもう少し大きいようです。 –

0

EditTextビューの高さはそれぞれ0dp、layout_weightという値を1ずつ与えてみてください。

+0

weightがrelative_layoutで動作するかどうかはわかりませんか? – PravinCG

+0

そうかもしれません。それは私がAndroidのUIを行ってからしばらくしていたので、私は錆びています。 :) – kcoppock

+0

重量はrelative_layoutで動作しません:)答えに感謝! –