![](/img/trans.png)
[英]how can I add attribute to the android activity from plugin.xml in cordova?
[英]How can I add image from src attribute to gradient.xml file in Android?
我是Android的新手,我想顯示帶有漸變背景的圖像。 是否可以將圖像添加到gradient.xml?
下面是用於此目的的xml代碼。
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<bitmap android:src="@drawable/bg"/>
<shape>
<gradient
android:startColor="#631f68"
android:endColor="#ff5555"
android:angle="45"/>
</shape>
</item>
解:
在您的main_activity.xml中,
為最頂層的布局設置背景圖片:(無論您使用的是相對還是約束)
然后采用另一種布局,並為match_parent提供高度和寬度,並將以下Gradient應用於其背景。
漸變文件:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="135"
android:centerColor="@color/colorAccentSecondary"
android:endColor="@color/colorPrimary"
android:startColor="@color/colorAccent"
android:type="linear" />
<corners android:radius="0dp" />
</shape>
希望能幫助到你。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.