Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/231.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在xml Drawable格式的图像上放置左边框线_Android_Imageview_Border_Line_Drawable - Fatal编程技术网

Android在xml Drawable格式的图像上放置左边框线

Android在xml Drawable格式的图像上放置左边框线,android,imageview,border,line,drawable,Android,Imageview,Border,Line,Drawable,我需要在imageview的左侧放一条橙色的线。我写了“艰难之路”,它奏效了: <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingRight="5dp" > <LinearLayout android:layout_width="5dp"

我需要在imageview的左侧放一条橙色的线。我写了“艰难之路”,它奏效了:

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:paddingRight="5dp" >

            <LinearLayout
                 android:layout_width="5dp"
                 android:layout_height="fill_parent"
                 android:background="#FF7F24" >
        </LinearLayout>

        <ImageView
             android:id="@+id/image1"
             android:layout_width="50dp"
             android:layout_height="60dp" 
          />

    </LinearLayout>

有没有一种方法可以直接在图像中使用可绘制的xml文件而不使用linearlayouts来实现此效果

谢谢你的帮助

您始终可以创建一个,并将其设置为线性布局的背景,而不是“#FF7F24”。
但是,由于您只需要纯色,我认为您实现它的方式很好

将下面的代码用作可绘制的imageview



我无法从src放置图像,因为我是从数据库加载的。当我尝试在背景中使用样式时,橙色线在图像中,但这不是我想要的效果。谢谢,如果我没有找到其他方法,我会保留此解决方案
<item>
    <shape android:shape="rectangle" >
    <solid android:color="#FF7F24" />
    </shape>
</item>
<item android:left="5dp">
    <bitmap android:shape="rectangle" 
        android:src="@drawable/image"/>
</item>