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의 "뒤로 보내기"
나는 이것을 시도 할 것이다. 마지막으로 나는 이미지를 framelayout 안에 넣지 않고 버튼 위에 표시하지 않을 것이다. 결과에 대한 업데이트를 게시합니다. – Greg432
몇 시간 동안 놀았지만 "중복 FrameLayout"없이는 오브젝트의 순서 (btn, tv, iv)와 상관없이 작동하지 않습니다. ImageView와 TextView는 절대로 다른 방식으로 표시되지 않습니다. 'background = ""'또는 이미지 버튼 대신'src = ""'를 사용해야합니까? – Greg432
좋아,'Button'을'ImageButton'으로 바꾸면됩니다. – Greg432