I want to develop custom layout for seekbar below shown.
I have track,thumb and progress images . Can any body help me?
XML code
<SeekBar
android:id="#+id/seekBar1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:progressDrawable="#drawable/seek_bar"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:thumb="#drawable/thumbler_small"
android:indeterminate="false" />
seek_bar.xml
<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="#+android:id/SecondaryProgress"
android:drawable="#drawable/first"/>
<item
android:id="#+android:id/progress"
android:drawable="#drawable/second"/>
</layer-list>
first drawable is empty or shown not color full area.
second drawable is fill or color full area.
this link help your more.
Related
I have created a vertical seek bar by adding android:rotation="270" in seekbar.
But i have been shared with a progress drawable which is vertical in position.
If i am applying this vertical image as progress drawable , seekbar is not looking fine.
can someone help me for this ?
layout:
<SeekBar
android:id="#+id/seekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="200"
android:progress="50"
android:rotation="270"
android:progressDrawable="#drawable/seek_bar"
/>
seek_bar.xml :
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="#android:id/background"
android:drawable="#drawable/seek_bar_background"/>
<item android:id="#android:id/progress"
android:drawable="#drawable/seek_bar_progress" />
</layer-list>
Here seek_bar_background.png and seek_bar_progress.png are vertical images
Here is my button image file from my drawable folder called ooo.png:
And that's how it looks like on the device:
As you can see the width height proportion changed. It's a bit wider than the original.
I need it to be looking the same though.
I don't understand what causes this stretching. Here is my xml-file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:id="#+id/button1"
style="#style/styleBtns"
android:layout_gravity="center_horizontal"
android:layout_marginTop="50dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
My styleBtns-part of the styles.xml:
<style name="styleBtns" >
<item name="android:background">#drawable/btns_abc</item>
</style>
And in my btns_abc I set the background to my image resource. Currently state pressed and the normal state are the same, I want to change that as soon as it works properly:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="#drawable/ooo" android:state_pressed="true"></item>
<item android:drawable="#drawable/ooo"></item>
</selector>
Thanks !
I don't know the exact reason but for a solution if u don't have any text for button ,use ImageView will show the same drawable u have added.
I have two buttons in bottom of screen, but how can I style stock buttons to style of my concept:
Here my code layout file:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<Button
android:id="#+id/button1"
android:layout_height="wrap_content"
android:layout_width="180sp"
android:text="Далее"
android:layout_weight="1"
android:layout_gravity="bottom"
android:layout_alignTop="#+id/button2"
android:layout_alignParentRight="true">
</Button>
<Button
android:id="#+id/button2"
android:layout_width="180dp"
android:layout_height="wrap_content"
android:text="Пропустить"
android:layout_weight="1"
android:layout_gravity="bottom"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true">
</Button>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Добро пожаловать!"
android:id="#+id/textView"
android:layout_marginTop="29dp"
android:fontFamily="sans-serif-thin"
android:phoneNumber="false"
android:textSize="33sp"
android:textColor="#color/text_color"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_marginLeft="25dp" />
</RelativeLayout>
There is multiple ways to do this when building an android application.
The first and simplest is to set your background to an image. To do this add a image to your drawable folders in the res folder, add the correct size images to each drawable folder to correct display across multiple platforms. Once you have imported your image simply put the following line in the layout xml for your button
android:background = "#drawable/imported_image"
The second is to create an selector android XML file. This will let you set the background image for different states of the buttons. I usually create a file under my res folder in my project called drawable and put the xml file there. The selector file would look something like this
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_pressed="true" android:drawable="#drawable/large_button_on" />
<item android:drawable="#drawable/large_button_off" />
</selector>
the code to put in your Layout xml inside your button should be
android:background="#drawable/custom_button"
The final way without using any images is to define a shape android xml file for the button. This will instruct how you want the button to be drawn on screen. This xml should be placed in your project the same way we did with the other.
?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:startColor="#000000"
android:endColor="#0000ff"
android:angle="270" />
<stroke android:width="1dp" android:color="#ffffff" />
</shape>
again if you use this method put the following in your layout xml for your button
android:background="#drawable/custom_button"
Hope these methods of styling help.
You can create an drawable xml file like this and have a different drawable for the different states of you button
res/drawable/my_button_drawable.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#drawable/button_pressed"
android:state_pressed="true" />
<item android:drawable="#drawable/button_focused"
android:state_focused="true" />
<item android:drawable="#drawable/button_default" />
</selector>
Then in your button's declaration add the line:
android:background="#drawable/my_button_drawable" />
Android Developer Buttons
In my application I have a SeekBar. I applied a custom drawable to it using layer-list
my code is `
<?xml version="1.0" encoding="UTF-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="#+android:id/background"
android:drawable="#drawable/profilecompleteness" />
<item
android:id="#+android:id/progress"
android:drawable="#drawable/profilecomplete_fill" />
</layer-list>`
and code for SeekBar is
<SeekBar
android:id="#+id/user_profile_progressBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:progressDrawable="#drawable/custom_seekbar"
android:thumb="#drawable/transparent" />
when use this code my seek bar displays only half image of drawable. How to can I show full image in the drawable.
I have a problem with changing button background image.
So i have 2 images (png-24 transparent background).
Images are a simple circle and the same circle but with some outerglow ).
I have the following code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ticketing_row_topup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#layout/pressed_topup_button"
android:orientation="horizontal" >
<TextView
android:id="#+id/topup_name"
android:layout_width="60dp"
android:layout_height="fill_parent"
android:gravity="center_vertical|right"
android:paddingRight="5dip"
android:paddingTop="22dip"
android:text="€"
android:textColor="#color/black"
android:textSize="35sp"
android:textStyle="bold" />
<TextView
android:id="#+id/topup_display_amount"
android:layout_width="90dp"
android:layout_height="match_parent"
android:gravity="center_vertical|left"
android:textSize="65sp"
android:textColor="#0d457f"
android:textStyle="bold" />
</LinearLayout>
And the pressed_topup_button.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" android:state_enabled="false">
<item android:state_pressed="true" android:state_enabled="true" android:drawable="#drawable/button_topup_glow" />
<item android:state_focused="true" android:state_enabled="true" android:drawable="#drawable/button_topup" />
<item android:state_enabled="true" android:drawable="#drawable/button_topup" />
</selector>
The LinearLayout is used to populate a GridView in each cell.
When i click the cell the behavior is correct (the glow is displayed) but also a yellow color is display on the corner of the image (where suppose to be transparent). How can i fix that?
Thanks
You need to add
android:listSelector="#android:color/transparent"
to your GridView declaration.
See this:
Android: Disable highlighting in GridView