简体   繁体   English

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

[英]Icon's size in Custom Layout Android

I want to change the size of my app's icon in Custom Title bar. 我想在“自定义标题”栏中更改应用程序图标的大小。 Here's my code so far: 到目前为止,这是我的代码:

<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>

My styles.xml file is: 我的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>

This produces an icon on the left of the title bar but how can I change the icon's size ? 这会在标题栏的左侧生成一个图标,但是如何更改图标的大小呢? I want the icon to be a little larger. 我希望图标更大一些。

Maybe you should just set specific DP attributes for your ImageView. 也许您应该只为ImageView设置特定的DP属性。 Stick with DP, and is will scale fine on all devices. 坚持使用DP,它将在所有设备上正常缩放。 Like this: 像这样:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM