自定义版式Android中图标的大小

Abd*_*han 2 xml icons android android-imageview

我想在“自定义标题”栏中更改应用程序图标的大小。到目前为止,这是我的代码:

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical"
android:paddingLeft="5dip"
android:background="#000000">

<ImageView
    android:id="@+id/header"
    android:src="@drawable/ic_launcher"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:adjustViewBounds="true"
    android:scaleType="fitXY"/>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

我的styles.xml文件是:

  <style name="CustomWindowTitleBackground">
    <item name="android:background">#00000000</item>
    </style>

   <style name="CustomTheme" parent="android:Theme">
    <item name="android:windowTitleSize">30dip</item>

    <item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item>
</style>
Run Code Online (Sandbox Code Playgroud)

这会在标题栏的左侧生成一个图标,但是如何更改图标的大小呢?我希望图标更大一些。

Boo*_*ger 5

也许您应该只为ImageView设置特定的DP属性。坚持使用DP,它将在所有设备上正常缩放。像这样:

<ImageView
    android:id="@+id/header"
    android:src="@drawable/ic_launcher"
    android:layout_width="48dp"
    android:layout_height="48dp"
    android:adjustViewBounds="true"
    android:scaleType="fitXY"/>
Run Code Online (Sandbox Code Playgroud)