0
border.xmlテキストビューの周りに境界線を置く方法は? (描画可能フォルダ内)
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<shape xmlns:android="http://schemas.android.com/apk/ res/android">
<stroke android:width="2dp"
android:color="#000"/>
<corners android:radius="10dp" />
<padding android:left="10dp"
android:top="5dp"
android:right="10dp"
android:bottom="5dp"/>
</shape>
</selector>
activity_main.xml
<TextView
android:id="@+id/textView"
android:layout_width="100dp"
android:layout_height="20dp"
android:layout_marginBottom="16dp"
android:layout_marginEnd="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:background="@drawable/border"
android:text="TextView"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
私は上記のコードを使用してのTextViewに境界線を取得することができません。制約レイアウトの幅と高さは、match_parentに設定されています。
コンテンツをラップするために幅と高さを設定します。 TextViewから制約を削除する –
border.xmlからセレクタとパディングを削除する –
@ZakiPathan動作しません。それを試してみました。 –