Android 安卓工作室图标固定
我正在为一个食谱应用程序做一个项目。我面临的问题是,当我在应用程序中输入配方描述时。图标随文本一起移动。是否有方法使用活动中的xml或代码将图标固定在版面中的特定位置 以下是问题的图片: 代码如下:Android 安卓工作室图标固定,android,xml,android-studio,android-layout,android-icons,Android,Xml,Android Studio,Android Layout,Android Icons,我正在为一个食谱应用程序做一个项目。我面临的问题是,当我在应用程序中输入配方描述时。图标随文本一起移动。是否有方法使用活动中的xml或代码将图标固定在版面中的特定位置 以下是问题的图片: 代码如下: <android.support.v7.widget.CardView android:id="@+id/cardViewList" android:layout_width="match_parent" android:layout_height="wrap_content" xmlns:
<android.support.v7.widget.CardView
android:id="@+id/cardViewList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="12dp">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name"
android:textSize="18sp"
android:textStyle="bold" />
<TableRow
android:id="@+id/trPersonsTimeDetails"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_alignParentLeft="true"
android:layout_marginTop="3dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/recipe_icon"
android:layout_width="33dp"
android:layout_height="match_parent"
android:background="@drawable/recipe_1" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Beschreibung"
android:textSize="16dp" />
</TableRow>
<TableRow
android:id="@+id/test"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/trPersonsTimeDetails"
android:layout_alignParentLeft="true"
android:layout_marginTop="3dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/time"
android:layout_width="33dp"
android:layout_height="33dp"
android:background="@drawable/timer" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/trPersonsTimeDetails"
android:text="Zeit"
android:textSize="16dp" />
</TableRow>
</RelativeLayout>
</android.support.v7.widget.CardView>
对于imageView,您应该使用参数
src
而不是background
,对于缩放问题,您需要scaleType=“fitCenter”
如下所示:
<ImageView
android:id="@+id/recipe_icon"
android:layout_width="33dp"
android:layout_height="match_parent"
android:scaleType="fitCenter"
android:src="@drawable/recipe_1" />
对于imageView,您应该使用参数
src
而不是background
,对于缩放问题,您需要scaleType=“fitCenter”
如下所示:
<ImageView
android:id="@+id/recipe_icon"
android:layout_width="33dp"
android:layout_height="match_parent"
android:scaleType="fitCenter"
android:src="@drawable/recipe_1" />
您只需将定义的大小设置为24dp x 24dp,然后将刻度类型更改为适合中心
您只需将定义的大小设置为24dp x 24dp,然后将刻度类型更改为适合中心
您的图标是否有标准的24dp x 24dp尺寸?您的图标是否有标准的24dp x 24dp尺寸?安卓:layout\u height=“33dp”修复了它!android:layout\u height=“33dp”修复了它!