Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/210.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 安卓工作室图标固定_Android_Xml_Android Studio_Android Layout_Android Icons - Fatal编程技术网

Android 安卓工作室图标固定

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:

我正在为一个食谱应用程序做一个项目。我面临的问题是,当我在应用程序中输入配方描述时。图标随文本一起移动。是否有方法使用活动中的xml代码将图标固定在版面中的特定位置

以下是问题的图片:

代码如下:

<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”修复了它!