AndroidスタジオでConstraintLayout
を使用してボタンの上に(上に)ImageView
とTextView
を重ねようとしています。以下は私が現在私のアプリに使っているものですが、RelativeLayoutsはすべてのデバイスサイズのレイアウトを作るのに非常に時間がかかります。ConstraintLayoutのボタンの上に画像を表示する
は、これが私のXMLである
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/frameLayout"
tools:layout_constraintTop_creator="1"
android:layout_marginStart="48dp"
android:layout_marginTop="24dp"
tools:layout_constraintLeft_creator="1"
ads:layout_constraintLeft_toLeftOf="parent"
ads:layout_constraintTop_toTopOf="parent"
android:layout_marginLeft="48dp">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/newfeedbtn"
android:background="@drawable/newsfeedbtn"
android:visibility="visible" />
</FrameLayout>
<ImageView
android:layout_width="27dp"
android:layout_height="25dp"
android:id="@+id/NFRedC"
android:layout_gravity="right|top"
tools:ignore="ContentDescription"
android:background="@drawable/alert"
android:gravity="center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ffffff"
android:id="@+id/NFTextNumber"
android:visibility="invisible"
android:text="0"
android:layout_gravity="right|top"
android:layout_marginRight="9dp"
android:layout_marginTop="3dp" />
</FrameLayout>
誰もが私は制約を使用してこれを行うことができます方法を知っていますか?レイアウト内のレイアウトを使わずに画像が表示される順序を指定する方法がありますか?例えば、。 Microsoft Officeの「返信」
私は最後に、画像をボタンの上に表示せず、フレームレート内に配置しませんでした。結果を更新します。 – Greg432
私はそれを数時間使っていましたが、オブジェクトの順序(btn、tv、iv)にかかわらず、 "冗長なFrameLayout"がなくても動作しませんでした。 ImageViewとTextViewは決して表示されません。 'background =" "'または画像ボタンの代わりに 'src =" "'を使うべきですか? – Greg432
'Button'を' ImageButton'に変更する必要があります – Greg432