I'm using VerticalSeekBar and I would like to set the width.
With the term width I mean the width of the seekbarbar progress part.
This is my xml
<com.h6ah4i.android.widget.verticalseekbar.VerticalSeekBarWrapper
android:layout_width="wrap_content"
android:layout_height="350dp"
android:layout_below="#+id/btnDate"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="15dp">
<com.h6ah4i.android.widget.verticalseekbar.VerticalSeekBar
android:id="#+id/verticaleDate"
android:layout_width="0dp"
android:layout_height="0dp"
app:seekBarRotation="CW270"
android:max="10"
android:splitTrack="false"/>
</com.h6ah4i.android.widget.verticalseekbar.VerticalSeekBarWrapper>
Thanks for interesting.
background_fill.xml:
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:angle="90"
android:centerColor="#FF555555"
android:endColor="#FF555555"
android:startColor="#FF555555" />
<corners android:radius="1dp" />
<stroke
android:width="1dp"
android:color="#50999999" />
<stroke
android:width="1dp"
android:color="#70555555" />
</shape>
progress_fill.xml:
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:angle="90"
android:centerColor="#FFB80000"
android:endColor="#FFFF4400"
android:startColor="#FF470000" />
<corners android:radius="1dp" />
<stroke
android:width="1dp"
android:color="#50999999" />
<stroke
android:width="1dp"
android:color="#70555555" />
</shape>
progress.xml:
<?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/background_fill"/>
<item android:id="#android:id/progress">
<clip android:drawable="#drawable/progress_fill" />
</item>
</layer-list>
thumb.xml:
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval" >
<gradient
android:angle="270"
android:endColor="#E5492A"
android:startColor="#E5492A" />
<size
android:height="20dp"
android:width="20dp" />
</shape>
Update your seekbar layout by this:
<com.h6ah4i.android.widget.verticalseekbar.VerticalSeekBarWrapper
android:layout_width="wrap_content"
android:layout_height="350dp"
android:layout_below="#+id/btnDate"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="15dp">
<com.h6ah4i.android.widget.verticalseekbar.VerticalSeekBar
android:id="#+id/verticaleDate"
android:layout_width="0dp"
android:layout_height="0dp"
android:progressDrawable="#drawable/progress"
android:thumb="#drawable/thumb"
app:seekBarRotation="CW270"
android:max="10"
android:splitTrack="false"/>
</com.h6ah4i.android.widget.verticalseekbar.VerticalSeekBarWrapper>
Related
I try to put a border for a button in android but unfortunately I can't see the button border.
Drawable File ๐
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<corners android:radius="12dp" />
<stroke android:width="3px" android:color="#7E8082" />
</shape>
</item>
</selector>
XML ๐
<Button
android:id="#+id/btn_signup"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginTop="122dp"
android:background="#drawable/bg_signup"
android:fontFamily="#font/poppins_semibold"
android:text="Create an Account"
android:textAllCaps="false"
android:textColor="#color/black"
app:layout_constraintTop_toBottomOf="#+id/btn_login" />
You don't need to use a custom drawable, just use a MaterialButton:
<com.google.android.material.button.MaterialButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="#style/Widget.MaterialComponents.Button.OutlinedButton"
app:strokeColor="#7E8082"
app:strokeWidth="1dp"
app:cornerRadius="12dp"/>
Don't use a selector for single option use shape directly
bg_signup
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#cdcdcd"/>
<corners
android:radius="4dp"
/>
<stroke
android:width="1dp"
android:color="#000"
/>
</shape>
use Style attribute instead of android:background="#drawable/bg_signup"
make a custom style then call it android:style="#style/bg_signup"
I was working on a project I can create a round button and set the gradient color but when I use it in Button background the color not changed.
rounded_shape.xml
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:startColor="#9bbbc1"
android:centerColor="#456268"
android:endColor="#456268"
android:angle="270" />
<corners
android:radius="25dp" >
</corners>
</shape>
Button in Xml
<Button
android:id="#+id/btn1"
android:layout_below="#+id/edttxt1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="80dp"
android:layout_marginTop="2dp"
android:layout_marginRight="80dp"
android:layout_marginBottom="2dp"
android:background="#drawable/rounded_shape"
android:padding="12dp"
android:paddingTop="2dp"
android:paddingEnd="2dp"
android:paddingBottom="4dp"
android:text="Analyse"
android:textAllCaps="false"
android:textColor="#android:color/white"
android:textSize="20dp"
android:textStyle="italic"></Button>
Try it in rounded_shape.xml :
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_pressed="true" >
<shape android:shape="rectangle" >
<corners android:radius="12dip" />
<stroke android:width="1dip" android:color="#333333" />
<gradient android:angle="-90" android:startColor="#333333" android:endColor="#555555" />
</shape>
</item>
<item android:state_focused="true">
<shape android:shape="rectangle" >
<corners android:radius="12dip" />
<stroke android:width="1dip" android:color="#333333" />
<solid android:color="#58857e"/>
</shape>
</item>
<item >
<shape android:shape="rectangle" >
<corners android:radius="12dip" />
<stroke android:width="1dip" android:color="#333333" />
<gradient android:angle="-90" android:startColor="#333333" android:endColor="#555555" />
</shape>
</item>
</selector>
The AppCompat library helps with bringing modern theming to your app on all Android versions, so change Button to androidx.appcompat.widget.AppCompatButton:
<androidx.appcompat.widget.AppCompatButton
android:id="#+id/btn1"
android:layout_below="#+id/edttxt1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="80dp"
android:layout_marginTop="2dp"
android:layout_marginRight="80dp"
android:layout_marginBottom="2dp"
android:background="#drawable/rounded_shape"
android:padding="12dp"
android:paddingTop="2dp"
android:paddingEnd="2dp"
android:paddingBottom="4dp"
android:text="Analyse"
android:textAllCaps="false"
android:textColor="#android:color/white"
android:textSize="20dp"
android:textStyle="italicโ/>
Hi i am developing an app where i have a custom curve shape which i'm using in an imageview now this shpae is in white color and i have created another similar custom shape in black color so now what i'm trying to do is make the black shape as shadow of white shape as a thin black line acting as a outline to white shape.
Now my problem is when i run the app the black shape is getting completely overlapped by white shape.
So please f anyone can help me out here
My xml code
<android.support.v4.widget.NestedScrollView android:layout_height="match_parent"
android:layout_width="match_parent"
android:fillViewport="true"
android:fitsSystemWindows="true"
android:id="#+id/profile_scroll"
xmlns:android="http://schemas.android.com/apk/res/android" >
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/background_image"
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="#drawable/curved_toolbar"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="250dp"
android:src="#drawable/curved_toolbar"
android:visibility="gone" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:layout_marginBottom="20dp"
android:src="#drawable/profile_black_shadow"/>
<ImageView
android:id="#+id/second_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:layout_marginBottom="20dp"
android:src="#drawable/profile_second_image" />
<ImageView
android:id="#+id/pencil_image"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_alignParentRight="true"
android:layout_marginRight="30dp"
android:scaleType="centerCrop"
android:adjustViewBounds="true"
android:layout_marginTop="25dp"
android:src="#drawable/pencil" />
</RelativeLayout>
<LinearLayout
android:id="#+id/linear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</LinearLayout>
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/circle_image"
android:layout_width="116dp"
android:layout_height="120dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginEnd="125dp"
android:layout_marginRight="125dp"
android:layout_marginTop="113dp"
android:src="#drawable/heath_ledger"
/>
<LinearLayout
android:id="#+id/person_name_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="10dp"
android:layout_below="#+id/circle_image"
android:layout_centerInParent="true"
>
<com.ct.listrtrial.Custom.CustomTextViewMedium
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Jhon Doe"
android:id="#+id/person_name_text"
android:textColor="#color/White"
android:textSize="16sp"/>
</LinearLayout>
<LinearLayout
android:id="#+id/points_layout"
android:layout_marginBottom="8dp"
android:layout_below="#+id/person_name_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="6dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="20dp">
<com.ct.listrtrial.Custom.CustomTextViewMedium
android:id="#+id/first_follow_count"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="200"
android:textColor="#color/White"
android:layout_marginLeft="13dp"
android:textSize="15sp"/>
<com.ct.listrtrial.Custom.CustomTextViewMedium
android:id="#+id/first_follow_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="13sp"
android:text="Followers"
android:textColor="#color/White"
android:layout_marginTop="5dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="51dp">
<com.ct.listrtrial.Custom.CustomTextViewMedium
android:id="#+id/second_follow_count"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="200"
android:layout_marginLeft="40dp"
android:textColor="#color/White"
android:textSize="15sp"/>
<com.ct.listrtrial.Custom.CustomTextViewMedium
android:id="#+id/second_follow_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="13sp"
android:text="Following"
android:textColor="#color/White"
android:layout_marginLeft="25dp"
android:layout_marginTop="5dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="100dp">
<com.ct.listrtrial.Custom.CustomTextViewMedium
android:id="#+id/third_follow_count"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="1.5K"
android:textColor="#color/White"
android:textSize="15sp"/>
<com.ct.listrtrial.Custom.CustomTextViewMedium
android:id="#+id/third_follow_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="13sp"
android:text="Points"
android:textColor="#color/White"
android:layout_marginTop="5dp"/>
</LinearLayout>
</LinearLayout>
<View
android:id="#+id/divider_view"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/black"
android:layout_above="#+id/leaderboard_recycler"/>
<android.support.v7.widget.RecyclerView
android:id="#+id/leaderboard_recycler"
android:layout_below="#+id/points_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
</android.support.v7.widget.RecyclerView>
<View
android:id="#+id/divider_view1"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/black"
android:layout_below="#+id/leaderboard_recycler"
/>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
and my custom white shape
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#FFFFFF"/>
<size
android:width="30dp"
android:height="15dp"/>
<corners
android:bottomLeftRadius="20dp"
android:bottomRightRadius="20dp"/>
</shape>
and my black shape
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#000000"/>
<size
android:width="18dp"
android:height="9.1dp"/>
<corners
android:bottomLeftRadius="55dp"
android:bottomRightRadius="55dp"
/>
</shape>
Try with this drawable (You can adjust shadow thickness by change padding in shapes),
like:-
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:top="0px">
<layer-list>
<item android:top="4dp">
<shape android:shape="rectangle">
<solid android:color="#08000000"/>
<corners
android:bottomLeftRadius="180dp"
android:bottomRightRadius="180dp" />
<size
android:width="80dp"
android:height="40dp"/>
<padding
android:bottom="3px" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="#09000000"/>
<corners
android:bottomLeftRadius="180dp"
android:bottomRightRadius="180dp" />
<size
android:width="80dp"
android:height="40dp"/>
<padding
android:bottom="2px"/>
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="#10000000"/>
<corners
android:bottomLeftRadius="180dp"
android:bottomRightRadius="180dp" />
<size
android:width="80dp"
android:height="40dp"/>
<padding
android:bottom="2px" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="#11000000"/>
<corners
android:bottomLeftRadius="180dp"
android:bottomRightRadius="180dp" />
<size
android:width="80dp"
android:height="40dp"/>
<padding
android:bottom="1px" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="#12000000"/>
<corners
android:bottomLeftRadius="180dp"
android:bottomRightRadius="180dp" />
<size
android:width="80dp"
android:height="40dp"/>
<padding
android:bottom="1px" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="#13000000"/>
<corners
android:bottomLeftRadius="180dp"
android:bottomRightRadius="180dp" />
<size
android:width="80dp"
android:height="40dp"/>
<padding
android:bottom="1px" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="#14000000"/>
<corners
android:bottomLeftRadius="180dp"
android:bottomRightRadius="180dp" />
<size
android:width="80dp"
android:height="40dp"/>
<padding
android:bottom="1px" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="#15000000"/>
<corners
android:bottomLeftRadius="180dp"
android:bottomRightRadius="180dp" />
<size
android:width="80dp"
android:height="40dp"/>
<padding
android:bottom="1px" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="#16000000"/>
<corners
android:bottomLeftRadius="180dp"
android:bottomRightRadius="180dp" />
<size
android:width="80dp"
android:height="40dp"/>
<padding
android:bottom="1px" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="#17000000"/>
<corners
android:bottomLeftRadius="180dp"
android:bottomRightRadius="180dp" />
<size
android:width="80dp"
android:height="40dp"/>
<padding
android:bottom="1px" />
</shape>
</item>
</layer-list>
</item>
<item >
<shape android:shape="rectangle">
<solid android:color="#ffffff"/>
<corners
android:bottomLeftRadius="180dp"
android:bottomRightRadius="180dp" />
<size
android:width="80dp"
android:height="40dp"/>
</shape>
</item>
</layer-list>
Set on ImageView like:-
<ImageView
android:background="#drawable/shape"
android:layout_width="match_parent"
android:layout_height="200dp" />
Result:-
I'm trying to make my custom seekbar.
This is what i try to do:
and this is what I succeed to do:
How to add this circles behind my progress?
Here is my code:
<SeekBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:progressDrawable="#drawable/progress"
android:thumb="#drawable/unnamed"
android:id="#+id/risk_seek_bar"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
progress.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape
android:shape="rectangle">
<solid android:color="#00FF0000" />
<padding android:bottom="1dp"/>
</shape>
</item>
<item
android:id="#android:id/background"
android:drawable="#drawable/background_fill"/>
<item android:id="#android:id/progress">
<clip android:drawable="#drawable/progress_fill" />
</item>
</layer-list>
background fill.xml
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:angle="90"
android:centerColor="#FF555555"
android:endColor="#FF555555"
android:startColor="#FF555555" />
<corners android:radius="10dp" />
<stroke
android:width="1dp"
android:color="#50999999" />
<stroke
android:width="1dp"
android:color="#70555555" />
</shape>
progress_fill.xml
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:angle="90"
android:centerColor="#FFFF4400"
android:endColor="#FFFF4400"
android:startColor="#FFFF4400" />
<corners android:radius="10dp" />
<stroke
android:width="1dp"
android:color="#50999999" />
<stroke
android:width="1dp"
android:color="#70555555" />
</shape>
You can use any of the following libraries
range-slider-view
material-range-bar
range-bar
How to change the text color of the keys?
Here is my keyboard layout.
<?xml version="1.0" encoding="UTF-8"?>
<android.inputmethodservice.KeyboardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/keyboard"
android:keyBackground="#drawable/key_background"
android:background="#color/keyboard_background"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:keyPreviewLayout="#layout/preview" />
key_background.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- Bottom 2dp Shadow -->
<item android:top="4dp"
android:left="2dp"
android:right="2dp">
<shape android:shape="rectangle" >
<solid android:color="#color/key_shadow" />
<corners android:radius="4dp"/>
</shape>
</item>
<!-- White Top color -->
<item android:bottom="4px"
android:top="4dp"
android:left="2dp"
android:right="2dp">
<shape android:shape="rectangle" >
<solid android:color="#color/white" />
<corners android:radius="4dp" />
</shape>
</item>
</layer-list>
Please look into this you will get an idea for your problem.
http://developer.android.com/reference/android/inputmethodservice/KeyboardView.html
android:keyTextColor="your color code"
U can use android:keyTextColor attribute: like
android:keyTextColor="#android:color/black"