Android 中的调整图标 + 文本按钮
Resize Icon + Text Button in Android
我创建了一个带有图标的文本按钮。但是我的图标更大。如何为每种分辨率创建不同的图像尺寸?
注意:我使用的是 Android Studio 2.2.3
这是我的 XML 文件:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.asus.teacher.TeacherActivity">
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_eye"
android:text="Drawable left"
android:textSize="10dp"
/>
</RelativeLayout>
How can I create different image size for each resolution
有几种方法:
还有第三方库会在不同的文件夹中生成图像,如hdpi , xhdpi , mdpi
等。你可以使用Drawable Resizer
也有用于此目的的在线工具。喜欢This
对于xml:您可以设置高度、宽度、填充、边距、重力等。
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:padding="4dp"
android:drawableLeft="@drawable/ic_eye"
android:text="Drawable left"
android:textSize="10sp"
/>
您可以使用 iconify
调整图标大小
您也可以使用 ImageButton 并将 "adjustViewBound" 属性设置为 true 这样您只需固定宽度和高度即可根据比例进行调整。
我创建了一个带有图标的文本按钮。但是我的图标更大。如何为每种分辨率创建不同的图像尺寸?
注意:我使用的是 Android Studio 2.2.3
这是我的 XML 文件:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.asus.teacher.TeacherActivity">
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_eye"
android:text="Drawable left"
android:textSize="10dp"
/>
</RelativeLayout>
How can I create different image size for each resolution
有几种方法:
还有第三方库会在不同的文件夹中生成图像,如
hdpi , xhdpi , mdpi
等。你可以使用Drawable Resizer也有用于此目的的在线工具。喜欢This
对于xml:您可以设置高度、宽度、填充、边距、重力等。
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:padding="4dp"
android:drawableLeft="@drawable/ic_eye"
android:text="Drawable left"
android:textSize="10sp"
/>
您可以使用 iconify
调整图标大小您也可以使用 ImageButton 并将 "adjustViewBound" 属性设置为 true 这样您只需固定宽度和高度即可根据比例进行调整。