だから私は私を夢中にさせる問題を抱えています。アプリの目的を知ることは重要/関連性がないため、xml ファイルからコードを貼り付けます。レイアウトは ですRelativeLayout
が、私が抱えている問題はこの の中にありますLinearLayout
。コード:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/background_orange"
android:id="@+id/rel_layout" >
<RelativeLayout
android:id="@+id/layout_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="false"
android:layout_centerHorizontal="true">
<ImageView
android:id="@+id/component_1"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:src="@drawable/source1"
/>
<ImageView
android:id="@+id/component_2"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_above="@id/component_1"
android:src="@drawable/source2"
android:layout_alignRight="@id/component_1"
android:layout_marginRight="-50dip"
android:layout_marginBottom="-25dip"
/>
</RelativeLayout>
<LinearLayout
android:id="@+id/problemIsHere"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="horizontal"
>
<EditText
android:id="@+id/edit_text"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="What's your question?"
android:imeOptions="actionDone"
android:inputType="textCapSentences|textAutoComplete"
android:textSize="25sp"
android:layout_gravity="left"
android:textStyle="bold" />
<ImageButton
android:id="@+id/image_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dip"
android:layout_weight="0"
android:layout_gravity="right"
android:background="@drawable/source3"
/>
</LinearLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="@id/problemIsHere"
android:gravity="center"
>
<ImageView
android:id="@+id/image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/source4"
android:onClick="computeUserInput" />
<ImageButton
android:id="@+id/image_button0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/image_view"
android:layout_alignTop="@id/image_view"
android:layout_marginLeft="-2dip"
android:background="@drawable/voice_recognition_touse"
/>
</RelativeLayout>
繰り返しますが、これは親の中にネストされていRelativeLayout
ます。プレビューで、[Graphical Layout] タブをクリックすると、これはまさに私が望むものと同じように見えます。EditText
小さい の左側に、ImageButton
正しい縦横比と余白があります。ただし、これを自分のデバイスで実行すると、LinearLayout
が逆になり、 が の右側にあることを意味EditText
しImageButton
ます。ただし、比率と余白はまだ正確です。ここで何がうまくいかないのか誰か知っていますか?
注: 既にプロジェクトをクリーンアップして更新しました。これは効果がありませんでした。layout_gravity
また、属性を削除しようとしましたが、何もしませんでした。
ありがとう