enter image description hereI am a beginer in Android doing an internship and i have been given the task to complete this navigation drawer for the app.Any help would be highly appreciated
Create new drawable and add the following code:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<corners android:topLeftRadius="20dp" android:bottomRightRadius="20dp"/>
<solid android:color="#color/semi_transparent_white"/>
</shape>
</item>
</selector>
Related
I'm trying to do a custom circular seekbar but i haven't being able to achieve this shape yet.
The problem is basically that long circle shape because i did a custom circular seekbar before:
This is the code from the second picture:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape
android:shape="ring"
android:thicknessRatio="16"
android:useLevel="false">
<solid android:color="#color/black" />
</shape>
</item>
<item>
<rotate
android:fromDegrees="270"
android:toDegrees="270">
<shape
android:shape="ring"
android:thicknessRatio="16"
android:useLevel="true">
<solid android:color="#color/green" />
</shape>
</rotate>
</item>
</layer-list>
I've tried changing the size but it obviously give it a different form:
Does anyone have any clue for me to get this?
I want to create a drawable file like the below screenshot.
My drawable xml file:
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:top="0px"
android:left="0px"
android:right="0px"
android:bottom="0px">
<shape android:shape="rectangle">
<corners android:radius="#dimen/_6sdp" />
<solid android:color="#color/activeslots"/>
</shape>
</item>
<item
android:top="#dimen/_14sdp"
android:left="#dimen/_12sdp"
android:right="#dimen/_58sdp"
android:bottom="#dimen/_14sdp">
<shape android:shape="oval">
<solid android:color="#color/white"/>
<size android:height="#dimen/_20sdp"
android:width="#dimen/_20sdp"/>
</shape>
</item>
</layer-list>
I created rectangle and oval inside the layer_list. But the issue is it is not working in different mobiles, also the white circle inside the drawable is becomes big after setting height and width.
I am developing an android App. I am using a drawable xml file to draw an arc.
My Problem
I want to change a particular attribute's value in the drawable xml file programmatically.
I want to change android:dashWidth attributes value using java code.
Steps Taken
I searched stackoverflow , But there are only answers for changing color in the drawable xml .(So may not be a duplicate question)
Here my code :
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="oval">
<size
android:height="56dp"
android:width="56dp"/>
<stroke
android:width="6dp"
android:color="#cccccc"/>
</shape>
</item>
<item>
<shape android:shape="oval">
<size
android:height="50dp"
android:width="50dp"/>
<stroke
android:width="6dp"
android:dashGap="140dp"
android:dashWidth="79dp" <!-- want to CHANGE this -->
android:color="#ecc807"/>
</shape>
</item>
</layer-list>
Here I want to change the android:dashWidth attribute's value using java code.
How to achieve this ?
I am using this (https://github.com/ganfra/MaterialSpinner) for my spinner in my project. The problem is i did't find any way to change the spinner's background. I've try to use android:background="#fff", then try to use android:theme="#style/myspinnertheme" which is changeing the background but still did't work. I don't know another way i can try :D
<fr.ganfra.materialspinner.MaterialSpinner
android:id="#+id/spCategory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:background="#fff"
app:ms_baseColor="#color/colorAccent"
app:ms_floatingLabelText="Kategori"
app:ms_enableErrorLabel="true"
app:ms_hint="Pilih Kategori : "/>
This is my project screen shoot :
Look at the spinner at bottom, i want to change the background color to white, what shall i do?
It happens because material spinner set background resources in constructor and changes your background. So just reset background resources with your color. Example:
Create background.xml in drawable( colors for default, pressed and selected spinner's state)
<?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">
<solid android:color="#android:color/darker_gray"/>
</shape>
</item>
<item android:state_selected="true">
<shape android:shape="rectangle">
<solid android:color="#android:color/darker_gray"/>
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="#android:color/black"/>
</shape>
</item>
And set it
MaterialSpinner spinner = (MaterialSpinner) findViewById(R.id.spCategory);
spinner.setBackgroundResource(R.drawable.background);
You can use custom:ms_baseColor="#color/green"
I am creating a tic tac toe program. I can get the buttons to display an X or 0 but I can't get them to display different colours. How would I do this?
Use a selector to change button color when clicked.
/res/drawable/btn_selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" >
<shape>
<solid android:color="#ffaa66"/>
</shape>
</item>
<item>
<shape>
<solid android:color="#ffdd99"/>
</shape>
</item>
</selector>
And now apply this xml as android:background to the button.