我只看了一张卡片,在它的背景上涂上了黑色,在输出中用了文本视图和背景图像,并将不透明度传递到textview
,以获得黑色图像。但是我不想对图像上的字体应用不透明度。请帮助。
这是密码。
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="140dp"
card_view:cardCornerRadius="10dp"
android:layout_margin="15dp"
card_view:cardElevation="20dp"
android:textColorHighlight="@color/cardview_dark_background"
app:cardBackgroundColor="#000000"
>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="ICE CREAM WITH CRANBERRY SYRUP"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:alpha="0.5"
android:background="@drawable/recp_one"
/>
</android.support.v7.widget.CardView>
最佳答案
对Textview
应用图像背景在您的情况下并不好,相反,您可以创建不同的ImageView
和Textview
并应用所需的任何属性。
应该像下面这样。
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="140dp"
card_view:cardCornerRadius="10dp"
android:layout_margin="15dp"
card_view:cardElevation="20dp"
android:textColorHighlight="@color/cardview_dark_background"
app:cardBackgroundColor="#000000"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/recp_one"
android:alpha="0.5"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="ICE CREAM WITH CRANBERRY SYRUP"
android:textAlignment="center"
android:textColor="#FFFFFF" />
</android.support.v7.widget.CardView>
关于android - 不想在Android中将不透明度传递给字体,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53846384/