0

少し問題があります。

カスタム ボタン ウィジェットを作成しています

<?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です。

アップデート

ボタンとフラグメントのレイアウトがあります。

4

2 に答える 2

0

私はあなたの問題が何であるかについて混乱しています。あなたのビューを相対レイアウトから外そうとしていますか? レイアウトを作成する場合、ビューは ViewGroup に属している必要があります。ビューがその属性「RelativeLayout」を定義するViewGroupの外にあるため、整列は機能しません

于 2012-06-18T19:04:33.217 に答える