layout_weight
を使用して、EditText
フィールドのすぐ右側にボタンを表示しようとしています。LayoutWeightsが正しく要素をスケーリングしない
しかし、これは何が起こるかです:
は私のデザインビューに見えるようにコンパイルされたバージョンを取得する方法はありますか?ここで
は私のデザインビュー
そして、ここでは私のレイアウトコードです:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:padding="10dp"
android:scrollbars="none"
tools:context="com.mycomapany.myapp.Views.MasterDetails.VehicleFragment">
<LinearLayout
android:id="@+id/llMainView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
../// OTHER ELEMENTS
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.design.widget.TextInputLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="2"
android:hint="VIN">
<android.support.design.widget.TextInputEditText
android:id="@+id/editVIN"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="5dp"
android:background="@color/COLOR_TXI_GREY"
android:imeOptions="actionDone"
android:inputType="text"
android:maxLength="17"
android:maxLines="1"/>
</android.support.design.widget.TextInputLayout>
<ProgressBar
android:id="@+id/pbCheckVIN"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="gone"/>
<Button
android:id="@+id/btnScanVIN"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/COLOR_TXI_BLUE"
android:text="SCAN"
android:textColor="@color/COLOR_TXI_WHITE"
android:textStyle="bold"/>
</LinearLayout>
../// OTHER ELEMENTS
</LinearLayout>
から
android:layout_marginEnd="5dp"
属性を削除してみてください。答えは問題を解決するかもしれないが、説明は多くの将来の問題を解決するかもしれない。問題を引き起こしていると思われるものと、その答えが解決する理由を含めるようにしてください。 – Newd@Newd android:layout_marginEndは、ビューの境界の外側にあるビューの最後の余分なスペースを指定します。これは、私は、EditTextとButtonの間のスペースを引き起こしていると思います。 – sats