I changed in ScrollView
android:fadeScrollbars="false"
to ScrollBar be visible and it works fine. My question is possible to change color of ScrollBar ? ( Default is gray and my background is gray so there is small contrast between ).
You can with android:scrollbarThumbVertical="#drawable/youdrawable
In my case, for instance yourdrawable is:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient android:startColor="#66C0C0C0" android:endColor="#66C0C0C0"
android:angle="45"/>
<corners android:radius="6dp" />
</shape>
You can use:android:scrollbarThumbVertical="#drawable/yourImage"
, where 'yourImage' can be a small 2 pixel image of ur desired color
Related
I am trying to achieve this layout. The upper part is a bit dark and it decreases as we move down making it complete transparent. I tried a couple of gradient variations but didn't get the desired results. Does anybody have idea of how to achieve this. Is it gradient or shadow ?
Create a gradient file and use this code you can increase or decrease transparency as you want
layout-->new file-->layout resource file--> give any name
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<gradient android:startColor="#B71A1A1A"
android:angle="270"
android:centerColor="#00FFFFFF"
android:endColor="#00FFFFFF"/>
</shape>
</item>
</selector>
I have a custom shape for button's dashed border. With hardcoded color everything works as expected, but I need to pass color from outside. How can I do it?
Here is my xml.
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid/>
<corners android:radius="16dip" />
<stroke
android:width="1dp"
android:color="#color/blue"
android:dashWidth="3dp"
android:dashGap="3dp"
/>
</shape>
</item>
</selector>
and this is usage
android:background="#drawable/dashed_border_button"
I need to change border color from hardcoded to dynamic
I achieved the same by using another Drawable resource file wit the attribute Stroke - Color = "your color"
and then setting the background Drawable to new Drawable file
yourview.setBackgroundResource(R.drawable.another);
This is because the method :
DrawableCompat.setTint(as.getBackground(),Color.BLUE);
Set even the solid fill color to the blue (here in this case) , which you don't want.
Hope it helps!!`
You need to get background() from your view and make
DrawableCompat.setTint(color, DrawableCompat.wrap(view.bacground())
I have the following element
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#drawable/black_border">
And black_border is:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<stroke
android:width="1px"
android:color="#000"/>
</shape>
The desired result is a 1px black border around the elements inside the LinearLayout.
On my device (running 5.0/Level 21) everything looks good, the contents of that element are grouped by a 1px black border.
However, the min sdk my app will support is level 10/2.3 and when I run the app in the emulator the whole background of the LinearLayout is black. It seems like
it is treating the stroke as a fill.
Has anyone come across this?
Edit: I gave the black_border a stroke of white, this somewhat solved my problem. TextViews inside the LinearLayout had no visible border with this change, so a subsequent step was needed to give them a border.
I had the same issue with api level 9.
You have to explicity tell that the solid is transparent.
Try this:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
<stroke android:color="#color/colorPrimaryDark" android:width="2dp" android:height="2dp"/>
<solid android:color="#color/trasparent" android:width="2dp" android:height="2dp"/>
<size
android:width="10dp"
android:height="10dp"/>
</shape>
where colorPrimaryDark is defined as black (#FF000000) and transparent is #00000000
I suggest you to use dp for dimensions instead of px.
I got round this by giving black_border a stroke of white. Subsequently I needed to give any TextViews inside the LinearLayout a border as having a white background made them borderless.
This question already has answers here:
Create alpha gradient on image to create fade effect
(2 answers)
Closed 6 months ago.
I need to create an alpha-gradient on the edge of the ImageView. Preferably using only XML.
Image for example
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#00FFFFFF"
android:endColor="#FFFFFFFF"
android:type="linear" />
</shape>
perfect transperancy. Make sure that the View below gradient is actually below and not just touching Gradient shape View.
If you have main RelativeLayout, ListView and View(Background:Gradient )
make sure that Gradient View is on top, of the ListView, and not a side. If Your gradient is aside it will be transparent by RelativeLayout Background Color and not by ListView .
i hope you understand what i want to say.
For transparency :
android:startColor="#null"
Or you can use a 8-digit hex color like that :
android:startColor="#FF000000"
The first two FF are for the alpha of the color, 00 is fully transparent and FF opaque
Need to code a custom ImageView if you want colorless transparency.
If your background is a static color, here's my preferred workaround:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#drawable/your_image"/>
<item>
<shape android:shape="rectangle">
<gradient android:startColor="#00efefef"
android:endColor="#ffefefef"
android:angle="270"
android:type="linear"/>
</shape>
</item>
</layer-list>
I want to show edit text box with two sides. so, for that i need to create a rectangle shape with two sides. PLease help some one.
create a drawable under drawable folder and add the belwow contents (border.xml:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<solid android:color="#color/black" />
<stroke android:width="1dip" android:color="#color/white"/>
</shape>
Now set the Background of the EditText to this draw able like :
android:background="#drawable/border"
I think the best way to do this is to create a 9-patch in PhotoShop with required border sides... there are also several other ways... depends on your design.