Create button like this in android 2.3.3 - android

How can I create a button like this in android 2.3.3 (Eclipse):

You can use HoloEverywhere. This is an open source
https://github.com/ChristopheVersieux/HoloEverywhere

You can implement with ImageView for that, you create an image with holo effect and place it as android:src="#drawable/holo_img" inside the imageview

Try to create custom button, you can create any shape by coding in xml file for example
here is my code for creating button with round corners
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#FFFDD0"/>
<corners android:bottomLeftRadius="8dip"
android:topRightRadius="8dip"
android:topLeftRadius="8dip"
android:bottomRightRadius="8dip"
/>
<stroke android:width="1px" android:color="#000000" />
</shape>
change this code according to your requirement.

Related

How can I make this type of custom EditText UI?

I am trying to put borders on edit text and put a label on it. I have tried this one.
<stroke
android:width="2dp"
android:color="#color/colorPrimary"/>
<corners android:radius="15dp"/>
But I want the following one. Initially it will look like this.
After clicking it will be like this.
Would you please help?
use the material design Outline Box style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
this link may help you http://qaru.site/questions/1688917/custom-textinputlayout-android
As #ZahoorSaleem said, you can use the MaterialComponents for that.
You will need to add the design support library to your build file.
The layout would (simplified) look like this:
<TextInputLayout
android:hint="Label"
style="style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<TextInputEditText />
</TextInputLayout>
put the below code in drawable and use this attribute in edittext
android:background="#drawable/nameofdrawablefile"
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#CC0505"/>
<stroke android:width="2dp" android:color="#CC0505" />
<corners android:radius="5dp" />
</shape>

How to create a custom button?

This is an example of the buttons that I need to create
I want to create a button with the bottom border, I was able to create a button using layer-list, but now for each button I have to create a separate layer-list. Are there any ways to create one template and reuse it?
This is the code to create a button with a layer-list
background_button.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="#793838" />
<corners android:radius="10dp" />
</shape>
</item>
<item android:bottom="3dp">
<shape android:shape="rectangle">
<corners android:radius="10dp" />
<solid android:color="#4056b6" />
</shape>
</item>
</layer-list>
Use below link to create custom buttons for android.
http://angrytools.com/android/button/
You must do it programmatically, once you have created the layout of a button you can reuse it several times..
here one example but you can find more!
Creating multiple buttons programmatically: Android

How to make android round buttons

I have tried to search this a lot however I was not able to make the same buttons as in the picture for android.
I have been trying to use the following code but the button is not transparent and it doesn't have that nice rounding on the sides:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#ffffff" />
<corners android:radius="15dp" />
</shape>
Currently it looks like this
I want the EditTexts and the buttons to be transparent with a white border
It would be a great great help if someone could assist me on this.
Defining shape is proper approach. If you want it to be transparent with white border you need to avoid using solid tag and use stroke (that is the border).
So for example you will have this shape (let's call it bg_button.xml under drawable folder):
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke android:color="#android:color/white" android:width="1dp" />
<corners android:radius="15dp" />
</shape>
Apply then this to your views as background. This is an example:
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Facebook"
android:background="#drawable/bg_button"/>
Please try this not just on Android Studio editor but also on your emulator / device. Rendering of rounded corners on Android Studio editor can create problems.
Say you have a xml drawable called rounded_button
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="10dp">
<solid android:color="#6E6E6E"/>
<corners
android:bottomRightRadius="8dp"
android:bottomLeftRadius="8dp"
android:topLeftRadius="8dp"
android:topRightRadius="8dp"/>
</shape>
You then set the background of the button to the #drawable resource you created.

How to create a custom TextView Background Android?

I want to create a background for my TextView to look exactly like this one(Yellow Box).
After I create the image how do I go about setting the background to the TV?
Thanks!
for that you create simple image . then Convert in to nine patch here
after set background to that drawable
Example of Nine patch Image
Or you could create a shape drawable.
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#color/Yellow" />
<stroke android:width="#dimen/" android:color="#color/"/>
<corners android:radius="#dimen/"/>
<gradient
android:startColor="#color/"
android:centerColor="#color/"
android:endColor="#color/"
android:centerX="0.5"
android:centerY="0.5"
android:gradientRadius="100"
android:type="linear" />
</shape>
It can also be done using shape attribute.
I created a similar one for myself using the below.
<?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" /> //This should be the yellow color you want
<corners android:radius="5dp" /> //for rounded corners
<stroke
android:width="2dp"
android:color="#color/color_dark_blue" /> //for border if you wish any
</shape>
Create it as an xml file inside drawable (say myTextViewBg.xml).
Then add it as a background to your TextView as,
yourTextView:background="#drawable/myTextViewBg.xml"
You can set background of your textview
android:background="#drawable/myResouce"
or using java
mTextView.setBackgroundResource(R.drawable.myResouce);
But in your case create a relative layout then put an imageView and Textview inside it and adjust it according to your view.
In imageView use image which you in your question, expect text to change. And in textView use changeable text. Which you may change pragmatically as well.

Android create iphone-like Gradient

I need to create black iphone like gradient in my android application. Please view black gradient at the top in the image below. How to do it? Thanks
Something like this, perhaps?
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<gradient
android:startColor="#FF000000"
android:endColor="#FF8E8E8E"
android:angle="270"/>
</shape>
I've posted a blog about an Iphone look an Android:
http://www.dibbus.com/2011/06/android-gradient-toolbar/
You can find some examples of gradients and what is possible using xml and/or 9-pacth images.
You can create gradients in XML
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:type="radial" android:gradientRadius="400"
android:startColor="#88cce7" android:endColor="#075e81"/>
</shape>
This example is a round gradient but by changing type param you can create others.
Include this code in a xml file in your drawable folder and you can refer to that file when you set a background. ie. android:background="your drawable file"
I know this is an old question, but I was messing around to get this same effect for a customer who wants a copy of his iPad app on Android, this is what I came up with:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:angle="270"
android:centerColor="#FF333333"
android:centerY="2%"
android:endColor="#FF000000"
android:startColor="#FF8E8E8E" />
<corners android:radius="5dp" />
</shape>

Categories

Resources