LoginSignup
0

More than 5 years have passed since last update.

4.0.x系でTextViewでBorder指定して黒塗りされた時の対処

Posted at
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <stroke android:width="1dp" android:color="@color/base_gray" />
</shape>
<TextView
    android:background="@drawable/base_gray_border"
    android:gravity="center"
    android:text="テスト"
    android:textSize="18sp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

Borderを指定しようとして、こんなBorderだけ指定するファイルを書いた
1dpで@color/base_grayの色で塗られたボーダーがTextViewに着くはずだった・・・

5系だとBorderだけ表示されていたが、4.0系だとTextViewの中が黒塗りに!
Styleの関係とか・・・?

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid
        android:color="@color/white" />
    <stroke android:width="1dp" android:color="@color/base_gray" />
</shape>

solidで背景色も指定して黒塗りはなおりました。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0