我正在制作一个<layer-list>可绘制的.
我有我的背景图像,我希望第二层更小,但似乎无论我在我android:layer_width和我内部写的是什么android:layer_height.
第二层大小仍然相同.
这是我的xml:
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<item
android:drawable="@drawable/picuser"
android:layout_width="50dp"
android:layout_height="50dp" />
<item
android:drawable="@drawable/ic_launcher"
android:layout_width="10dp"
android:layout_height="10dp" />
</layer-list>
Run Code Online (Sandbox Code Playgroud) 嗨,我正在尝试drawable为我的启动画面创建一个背景,我将在主题中进行设置.但是用于保持在中心的位图drawable正在变得紧张,我无法弄清楚如何保持正常.下面是我的可绘制代码:
splash_screen_bg.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="360"
android:centerColor="@color/colorAccentXDark"
android:endColor="@color/Black"
android:gradientRadius="500dp"
android:startColor="@color/colorAccentXDark"
android:type="radial"
android:useLevel="false" />
</shape>
</item>
<item
android:bottom="50dp"
android:top="50dp">
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:innerRadius="500dp"
android:innerRadiusRatio="1"
android:shape="oval">
<gradient
android:angle="360"
android:centerColor="@color/colorAccentXDark"
android:endColor="@color/colorAccentXDark"
android:gradientRadius="400dp"
android:startColor="@color/colorAccent"
android:type="radial"
android:useLevel="false" />
</shape>
</item>
<item android:gravity="center">
<bitmap android:src="@drawable/ty_logo" />
</item>
</layer-list>
Run Code Online (Sandbox Code Playgroud)
这是我将此drawable设置为活动背景的代码:
<style name="TYTheme" parent="SearchActivityTheme.NoActionBar">
<item name="colorPrimaryDark">@color/colorAccentXDark</item>
<item name="android:alertDialogTheme">@style/AlertDialogTheme</item>
<item name="android:windowBackground">@drawable/splash_screen_bg</item>
</style>
Run Code Online (Sandbox Code Playgroud)
所以这里的bitmap drawable ty_logo正在png我的手机中拉长.由于没有scaleType选项,bitmapDrawable我不知道如何处理它.