Solution 1 :
Text with image = TextView
and TextView.setcompounddrawableswithintrinsicbounds()
slash = background for TextView
in xml android:background="@drawable/srcDrawable"
for example
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns_android="http://schemas.android.com/apk/res/android"
android_width="48dp"
android_height="48dp"
android_viewportWidth="24.0"
android_viewportHeight="24.0">
<path
android_fillColor="@color/primaryGreen"
android_pathData="M0,0
6,24
24,24
24,0
z"
android_strokeColor="@color/primaryGreen" />
</vector>
Solution 2 :
You can create the layout
normally with one Spinner
and One TextView
. You can set the background fo parent layout as android:background="@drawable/customBg
Create the below background as below.
<vector xmlns_android="http://schemas.android.com/apk/res/android"
android_width="100dp"
android_height="40dp"
android_viewportWidth="24.0"
android_viewportHeight="24.0">
<path
android_fillColor="@android:color/holo_blue_light"
android_pathData="M0,0
0,24
13,24
11,0
z" />
<path
android_fillColor="@android:color/holo_orange_light"
android_pathData="M11,0
13,24
24,24
24,0
z" />
</vector>
Problem :
I want to place a Textview and a Spinner in the same layout with a half background with a slash as shown in image
Comments
Comment posted by AgentP
If you are specifically talking about that slash I would have created a kind of bg image in photoshop and set it as bg ..
Comment posted by Ryan M
In the future, you should try to make your title sum up the problem in a way that is independent of images in the post to help people differentiate it from many other posts asking for layout help – it’ll also help you get more attention to your post. I’ve gone ahead and improved it a bit for you.