这是我的初始屏幕:
splash_screen.xml
<item android:drawable="@color/colorBackground"/>
<item android:width="50dp" android:height="50dp" android:gravity="center">
<bitmap
android:src="@drawable/truthordare_splash"
android:gravity="center" />
</item>
styles.xml
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:fontFamily">@font/play</item>
<item name="android:windowBackground">@drawable/splash_screen</item>
</style>
位图图像几乎占据了整个屏幕。我想减小其大小,但是更改父级width
的{{1}}和height
并没有任何作用。为什么会这样?
如何更改位图的大小?
答案 0 :(得分:1)
这种方法需要更高的API级别(也许是23个?),但它可以完全满足您的要求。
<item
android:height="200dp"
android:width="200dp"
android:drawable="@drawable/truthordare_splash"
android:gravity="center">
</item>
将宽度/高度编辑为您所需的任何宽度。希望对您有用
答案 1 :(得分:0)
将您的splash_screen.xml
更改为此:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_centerInParent="true"
android:id="@+id/logo"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="@drawable/truthordare_splash"/>
</RelativeLayout>