Seekbar rectangular corners - android-layout

I have a situation similar to this one, however, the method supposed there isn't working for me. I've tried different variation with tag but nothing has helped so far.
Here's my main.xml
<?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" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/hello" />
<SeekBar
android:id="#+id/seekBar1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="20"
android:progress="0"
android:secondaryProgress="0"
android:progressDrawable="#drawable/seekbar_progress" />
</LinearLayout>
drawable-mdpi/seekbar_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/passive_progress">
<shape>
<corners android:radius="0dp" />
</shape>
</item>
<item
android:id="#android:id/progress"
android:drawable="#drawable/active_progress">
<clip>
<shape>
<corners android:radius="0dp" />
</shape>
</clip>
</item>
</layer-list>
Thank you.

Related

Custom bottom navigation android studio icon

I'm trying to create a custom navView in my app but I get this weirdest bug.
I can't get the "menu" button to look like the others.
It's not pressed in the image, it just like that all the time.
this is my layout:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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"
tools:context=".activities.BottomNavView">
<FrameLayout
android:id="#+id/flFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="#+id/bottomNavigationView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/bottomNavigationView"
android:layout_width="match_parent"
android:layout_height="75dp"
android:theme="#style/NavTheme"
android:background="#drawable/toolbar"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0."
app:layout_constraintStart_toStartOf="parent"
app:menu="#menu/bottom_nav_bar"
app:itemIconSize="30dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
this is my theme:
<style name="NavTheme" parent="Theme.MaterialComponents.BottomSheetDialog">
<item name="colorPrimary">#color/colorBlack</item>
<item name="colorPrimaryDark">#color/black</item>
<item name="colorAccent">#color/colorBlue</item>
<item name="colorNavigationItemSelected">#color/colorGray</item>
</style>
itried Theme.MaterialComponents.Light.DarkActionBar as well.
this is my menu:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="#+id/list"
android:title="#string/menu"
android:enabled="true"
android:icon="#drawable/menu" />
<item
android:id="#+id/search"
android:title="#string/search"
android:enabled="true"
android:icon="#drawable/search"/>
<item
android:id="#+id/home"
android:title="#string/map"
android:enabled="true"
android:icon="#drawable/home"/>
<item
android:id="#+id/liked"
android:title="#string/heart"
android:enabled="true"
android:icon="#drawable/liked"/>
<item
android:id="#+id/add"
android:title="#string/plus"
android:enabled="true"
android:icon="#drawable/add"/>
</menu>
the image is
I can't understand why it's have the text beneath and this different look.
use labelVisibilityMode to unlabeled to remove the text under the menu item
app:labelVisibilityMode="unlabeled"

android studio background behind TextView

I'm trying to achieve something like this in Android Studio:
I don't want the background shape to be as the TextView size, I want it half the size just like the above image. This is what I tried to do:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:bottom="30dp">
<shape android:shape="rectangle" >
<solid android:color="#f3f3f3" />
</shape>
</item>
<item android:top="20dp">
<shape android:shape="rectangle" >
<solid android:color="#FFC107" />
</shape>
</item>
</layer-list>
and it looks like this:
not exactly what I wanted. how can I do it like in the image above?
Try this:
define in a res/drawable new file called double_color.xml :
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#+id/shape_rectangle">
<shape android:shape="rectangle" >
<solid android:color="#color/green" />
</shape>
</item>
<item android:top="-10dp" android:right="-10dp" android:left="-10dp">
<shape>
<solid android:color="#android:color/transparent" />
<stroke
android:width="10dp"
android:color="#android:color/white"/>
</shape>
</item>
</layer-list>
Than define a new style in res/values as:
<style name="TexViewStyle" parent="TextAppearance.AppCompat">
<item name="android:background">#drawable/double_color</item>
</style>
And last add style to your textView:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Full name"
style="#style/TexViewStyle"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Will be like this:

How to implement these type of Edittext?

enter image description here
They have little elevation effect and not outline box.
Just create an xml file in your drawable folder name as round_corner.xml.And add this following code.
<?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="#color/darkGray" />
<corners android:radius="7dp" />
</shape>
</item>
<item
android:bottom="3dp"
android:right="3dp">
<shape android:shape="rectangle">
<solid android:color="#android:color/white" />
<corners android:radius="7dp" />
</shape>
</item>
</layer-list>
At Last you add this xml in background property of your Edittext as follows:-
<EditText
android:id="#+id/ed1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/round_corner"
/>

Navigation Drawer header cuttoff by action bar

Navigation Drawer header cuttoff by action bar.But I need navigation drawer over action bar.My Navigation drawer show in image
My style .xml
<item name="actionBarStyle">#style/MyActionBar</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="actionBarTheme">#style/AppTheme.AppBarOverlay</item>
<item name="actionBarPopupTheme">#style/AppTheme.PopupOverlay</item>
</style>
<style name="MyActionBar"
parent="#style/Widget.AppCompat.ActionBar.Solid">
<item name="android:background">#color/sapphire_blue_light</item>
<item name="background">#color/sapphire_blue_light</item>
</style>
And Drawer layout i add this line alsio
android:fitsSystemWindows="true"
But i need result like below image.
Result image i need this
My drawer layout.
My customized navigation drawer.
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<FrameLayout
android:id="#+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.CoordinatorLayout
android:id="#+id/main_content"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_help"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"
android:clickable="true"
android:visibility="gone"/>
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
android:id="#+id/left_drawer_layout"
android:layout_height="match_parent"
android:layout_width="260dp"
android:layout_gravity="start"
android:fitsSystemWindows="true"
>
<LinearLayout
android:layout_width="260dp"
android:layout_height="match_parent"
android:layout_gravity="left"
android:background="#color/grey"
android:orientation="vertical"
>
<include layout="#layout/nav_header" />
<ListView
android:id="#+id/left_drawer_child"
android:layout_width="260dp"
android:layout_height="match_parent"
android:choiceMode="singleChoice"
android:divider="#color/listview_side_view"
android:dividerHeight="0dp"
android:background="#color/listview_side_view"/>
</LinearLayout>
</android.support.design.widget.NavigationView>
I think your problem is with theme MyActionBar :-
<style name="MyActionBar"
parent="#style/Widget.AppCompat.ActionBar.Solid">
<item name="android:background">#color/sapphire_blue_light</item>
<item name="background">#color/sapphire_blue_light</item>
</style>
Try after removing:-
<item name="background">#color/sapphire_blue_light</item>
If this not work try removing:-
<item name="android:background">#color/sapphire_blue_light</item>

How to get a round image button in android studio

I have tried to get an image button of round shape. But it is displaying the circular image with a square shaped background but i need only the image without any background.
I also used round_image.XML as background drawable file but its not working.
menu.xml
<ImageButton
android:id="#+id/imageButton1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:src="#drawable/sliderr" android:background="#drawable/round_image"/>
round_image.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"android:shape="oval">
<gradient android:startColor="#50d050
android:endColor="#008000" android:angle="270"/>
<stroke
android:width="1px"
android:color="#000000"/>
</shape>
Use this corner , instead of yours
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#color/colorPrimary" />
<stroke android:color="#color/colorPrimary" />
<corners
android:bottomLeftRadius="5dp"
android:bottomRightRadius="5dp"
android:topLeftRadius="5dp"
android:topRightRadius="5dp" />
</shape>

Resources