Heres the code
<LinearLayout
android:id="#+id/back"
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_gravity="center"
android:layout_marginTop="40dp"
android:background="#drawable/border_control"
android:orientation="vertical">
<Spinner
android:id="#+id/frmL"
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_marginTop="30dp"
android:textAlignment="center"
android:textColor="#color/black" />
and here's the <border_control>
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:color="#color/design_default_color_on_primary" android:width="1dp"/>
<corners android:radius="10dp"/>
<solid android:color="#color/design_default_color_on_primary"/>
</shape>
dark mode layout in it is the spinner
in normal mode, you can see the spinner
EDIT - so what i did was made another folder named values-night and copied the color.xml file in it and changed the colors i was using to more darker, now i detects if the system night mode is enabled it picks colors from value-night forlder
if anyone was having same problem you can also do what i did this also gives your app a dark mode.
Try to copy all from the values/themes.xml to the values-night/themes.xml. I'm sorry I can't make comments for now.
Related
i am loading an image from firebase storage using Picasso
Picasso.get().load(obj.P_URI).into(profile);
image lost its out line
it seem that it loaded into background i want it to load into src how can i do this XML below
<androidx.cardview.widget.CardView
android:id="#+id/cardView_profile_id"
android:layout_width="#dimen/_45sdp"
android:layout_height="#dimen/_45sdp"
android:layout_marginStart="#dimen/_10sdp"
android:layout_marginTop="#dimen/_10sdp"
android:elevation="5dp"
app:cardCornerRadius="360dp"
app:layout_constraintEnd_toStartOf="#+id/home_name_id"
app:layout_constraintBottom_toTopOf="#+id/home_HorizontalScrollView_id"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="#+id/home_profile_id"
android:layout_width="#dimen/_43sdp"
android:layout_height="#dimen/_43sdp"
android:layout_gravity="center"
android:background="#drawable/bg_circle"
android:clipToOutline="true"
android:outlineProvider="background"
/>
</androidx.cardview.widget.CardView>
i want image load like this
i just wanted the outline for circle profile and same time want to load image from the url it seem that Picasso can not load image into scr . changing xml to this way fixed my problem . hope this will help someone
XML
<androidx.cardview.widget.CardView
android:id="#+id/cardView_profile_id"
android:layout_width="#dimen/_65sdp"
android:layout_height="#dimen/_65sdp"
android:backgroundTint="#51CDC9"
android:elevation="5dp"
android:layout_marginTop="#dimen/_10sdp"
app:cardCornerRadius="360dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/imageView">
<ImageView
android:id="#+id/singup_profile_id"
android:layout_width="#dimen/_63sdp"
android:layout_height="#dimen/_63sdp"
android:layout_gravity="center"
android:background="#drawable/default_profile_icon"
android:clickable="true"
/>
<ImageView
android:id="#+id/profileRing_id"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="#drawable/bg_circle_edge" />
</androidx.cardview.widget.CardView>
in drawable bg_circle_edge
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:width="#dimen/_2sdp"/>
<stroke android:color="#color/white"/>
<corners android:radius="#dimen/_360sdp"/>
<corners android:radius="360dp"/>
</shape>
As seen in the image below, the second shortcuts the one with the letter T red.
How can I generate such an icon to be able to put it in the shortcuts in the icon attribute?
By setting up:
the color of the text
the background color
the number of letters
create a xml file in drawable folder, example this file name : "oval_text" and paste this code to xml file:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<gradient
android:angle="270"
android:startColor="#8ac53e"
android:endColor="#8ac53e"
android:type="linear" />
<size
android:width="90dp"
android:height="90dp"/>
And, create a xml file in folder layout :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_centerInParent="true"
android:src="#drawable/oval_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:textStyle="bold"
android:textSize="40dp"
android:textColor="#ffffff"
android:layout_centerInParent="true"
android:text="T"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
View this image:
I have a row of buttons each with numbers on them. I show which one is selected by changing the background, but one of these number would be the "current" number (kind of like a current date) and I want to indicate that it is the current one even when it is selected (since it will have the same background as all other selected ones) by adding a circle around the text
Kind of like this (with 23 being both selected and the current one):
I tried doing this by adding a radius to the button and adding padding but was having a bit of trouble, but even if it worked it feels like there is probably a better way.
How do I make the circle around the text in the button?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/num_txt"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginTop="0dp"
android:background="#drawable/bg_red"
android:gravity="center"
android:text="My name is NON"
android:textColor="#FFFFFF"
android:textSize="10dp" />
</RelativeLayout>
</RelativeLayout>
bg_red.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<corners android:radius="10dip"/>
<stroke android:color="#FF0000" android:width="5dip"/>
<solid android:color="#FF0000"/>
</shape>
or try This or This
I want to create a button with background color, icon and text in android.
But I don't know how to add image. My XML is:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="12dp"
android:orientation="vertical" >
<TableLayout
android:id="#+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp" >
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/button"
android:text="BOTON"
/>
</TableLayout>
</LinearLayout>
And my background:
<?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="6dip" />
<stroke android:width="1dip" android:color="#5e7974" />
<gradient android:angle="-90" android:startColor="#345953" android:endColor="#689a92" />
</shape>
</item>
</selector>
I want to make some like this:
how add background image plus text in my background button? I tried put icon with property android:drawableleft but the size was to little for the size of button...
This isn't actually that hard. I just had to do this for my own project.
Android Buttons have a drawableLOCATION property in the XML.
To put an image at the top, as you want it, you'd use
android:drawableTop="#drawable/your_drawable_icon"
All four possible options are:
android:drawableLeft
android:drawableRight
android:drawableBottom
android:drawableTop
To adjust the spacing/padding of the image icon, you can use
android:drawablePadding="12dp"
You can read more about this here.
If that isn't accurate enough for you, you can use a RelativeLayout and put stuff in it to look right.
I had to do that for my current project. So instead of the button, I had this for my XML:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:id="#+id/applianceInfoLayout"
android:clickable="true"
android:background="#drawable/button_background" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
android:layout_centerVertical="true"
android:layout_marginLeft="#dimen/service_menu_icon_padding"
android:layout_marginRight="#dimen/service_menu_icon_padding"
android:id="#+id/infoTextView"
android:src="#drawable/ic_applianceinfo"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
android:layout_centerVertical="true"
android:text="Info"
android:textColor="#E6E7E8"
android:fontFamily="sans-serif-light"
android:textAllCaps="false"
android:textSize="22sp"
android:layout_toRightOf="#id/infoTextView"/>
</RelativeLayout>
Which gave me this:
I am working on an Android app and I am going to implement a EditBox which will very like the Instagram one showing below:
Like the screen capture below, the area marked by the red line is a whole edit box (which means click anywhere, even the image, the editbox will get focus and keyboard will show up.) but only the right side of the blue line is the input text area.
Instagram Editbox http://snag.gy/CTWsK.jpg
The code I currently have is pretty trivial
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="10dp"
android:weightSum="1" >
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#drawable/rounded_edittext"
android:hint="Ho shot man"
android:inputType="textMultiLine"
android:layout_weight="1" />
</LinearLayout>
and drawable is defined as:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="10dp"
android:shape="rectangle" >
<solid android:color="#FFFFFF" />
<stroke
android:width="1dp"
android:color="#2f6699" />
<corners
android:bottomLeftRadius="10dp"
android:bottomRightRadius="10dp"
android:topLeftRadius="10dp"
android:topRightRadius="10dp" />
</shape>
I am not sure whether there is a layout cascade workaround I could do to make the editbox like the Instagram one, or if I need to extend the editbox to change its behavior? Pointers or code sample will be greatly helpful, thank you!
Try like this
<EditText
android:id="#+id/editthis"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/editbox"
android:hint="this this this"
android:padding="5dip"
android:singleLine="true"
android:textColor="#999999"
android:textSize="14dip"
android:drawableLeft="#drawable/ic_launcher" />
Drawable left the icon will be set in left side