少し問題があります。
カスタム ボタン ウィジェットを作成しています
<?xml version="1.0" encoding="utf-8"?>
<Button
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/barBtn"
android:layout_width="wrap_content"
android:layout_height="32dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:textColor="@color/white"
android:background="@drawable/sel_btn_bar"
android:layout_centerVertical="true"
/>
それから私はそれをRelativeLayout
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:scaleType="fitXY"
android:src="@drawable/bar"/>
<include layout="@layout/segm_btn_stores"/>
<include
layout="@layout/btn_bar"
android:layout_alignParentRight="true"/>
</RelativeLayout>
include
しかし、必要に応じて移動できるタグを配置するまで、整列は機能しませんRelativeLayout
。しかし、この方法は別の問題を引き起こしています: ボタンは外側にある場合よりも狭くなりますRelativeLayout
。私に何ができる?ボタンのパラメーターを 1 か所で設定したい。
android:layout_alignParentRight="true"
はい、次の行をButton
タグに追加できます。これで機能します。
問題は、なぜタグには機能し、Button
タグには機能しないのかということinclude
です。
アップデート
ボタンとフラグメントのレイアウトがあります。