How to customize GridView vertical scrollbar? - android

I tried changing scrollbar of GridView:
android:scrollbarThumbVertical="#drawable/scrollbar_vertical_thumb"
android:scrollbarTrackVertical="#drawable/scrollbar_vertical_track"
scrollbar_vertical_thumb.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:angle="0"
android:endColor="#005A87"
android:startColor="#007AB8" />
<corners android:radius="6dp" />
</shape>
scrollbar_vertical_track.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:angle="0"
android:endColor="#9BA3C5"
android:startColor="#8388A4" />
<corners android:radius="6dp" />
</shape>
But it's not working and gridview keeps showing original scrollbar.

please try
android:scrollbarAlwaysDrawVerticalTrack=true
android:scrollbars=vertical
if it didnt work then try android:scrollbarSize too

Related

How can i make clipped part layer-list using Android XML

enter image description here
XML :
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape>
<corners android:radius="20dp" />
<solid android:color="#fff" />
</shape>
</item>
</layer-list>
I want to make clipped part. How can I make the cropped piece above .
Try this :
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<corners
android:bottomLeftRadius="27dp"
android:bottomRightRadius="27dp"
android:topLeftRadius="0dp"
android:topRightRadius="0dp"
/>
<solid
android:color="#FFFFFF"
/>
</shape>
Modify this to be able to add a specific angle:
bottomLeftRadius
bottomRightRadius
topLeftRadius
topRightRadius

seekbar's background picture showed twice

Progress bar display twice.
My XML code:
Style :
How do I solve this problem?
you can add gradient like
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:angle="45"
android:endColor="#color/colorgreenheader"
android:centerColor="#color/color_neartowhite"
android:startColor="#color/color_grey_light" />
<corners android:radius="8sp" />
<size android:width="8sp"/>
<padding
android:left="0.5sp"
android:right="0.5sp" />
</shape>

Failed to parse file while assigning a shape to background

<?xml version="1.0" encoding="utf-8"?>
<gradient>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:type="linear"
android:centerX="35%"
android:startColor="#FF4D0000"
android:centerColor="#FF4D0000"
android:endColor="#FFe5f011"
android:angle="225"/>
</shape>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient android:type="radial"
android:centerX="50%"
android:centerY="50%"
android:startColor="#FF4D0000"
android:centerColor="#FF4D0000"
android:endColor="#FFe5f011"
android:gradientRadius="35"/>
</shape>
</gradient>
And here is the shape that I have formed called gradient and the way I assigned it, is:
android:background="#drawable/gradient"
Create one android xml file of type shape. give name as myshape.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:centerColor="#FF4D0000"
android:centerX="50%"
android:centerY="50%"
android:endColor="#FFe5f011"
android:gradientRadius="35"
android:startColor="#FF4D0000"
android:type="radial" />
</shape>
Now assign this file to the any layout with "#drawable/myshape"
I hope this will clear your doubts.
Bskania.

how to create rounded edittexts?

I am new to android, currently. I have created simple EditTexts and search bar type EditText .. But now I am stuck at creating attached EditTexts like in the following snapshot.
for 1st edit text:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="10dp"
android:shape="rectangle" >
<corners android:topLeftRadius="4dp"
android:topRightRadius="4dp" />
<solid android:color="#fff" />
<stroke
android:width="1dp"
android:color="#777" />
</shape>
second:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="10dp"
android:shape="rectangle" >
<solid android:color="#fff" />
<stroke
android:width="1dp"
android:color="#777" />
</shape>
third:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="10dp"
android:shape="rectangle" >
<corners android:bottomLeftRadius="4dp"
android:bottomRightRadius="4dp" />
<solid android:color="#fff" />
<stroke
android:width="1dp"
android:color="#777" />
</shape>
You could use parent LinearLayout view and make it roundtable using shapes (like the other answer). Then just put any number of EditText views and use separator view between them.
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<solid android:color="#ffffff" />
<stroke android:width="1dip" android:color="#000000"/>
<corners android:radius="3dp" />
</shape>
using the following xml code to create a new drawable and set it as background to your LinearLayout that contains EditViews.

Gradient shape blending position in LinearLayout

I have a requirement of achieving following type of gradient on my LinearLayout
Can someone help me to achieve this?
Try this:
<?xml version="1.0" encoding="utf-8" ?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#ffffff"
android:centerColor="#ffffff"
android:endColor="#ff0000"
android:angle="270"
/>
</shape>
defining in xml file you can get like this way
<?xml version="1.0" encoding="utf-8" ?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#ffffffff"
android:endColor="#ffff0000"
android:angle="270"
/>
<corners android:radius="1dp"/>
</shape>
save this in mygradientbg.xml into drawable folder
in you linearlayout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/gradient"
>
</LinearLayout>
but it will stretch with the width and height

Categories

Resources