Custom UI for button and edittext - android

I have been trying to design a button and a edittext in native android but unable to create the exact UI as shown in the picture. If anyone has any idea how can I create such UI please share your thoughts. In the image the first field should act as an input box and the second field should act as button.

The following given xmls will create the same UI you asked for. :)
create roundedbutton.xml resource file in drawable folder, given below
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#eeC4C6C7" />
<corners android:bottomRightRadius="30dp"
android:bottomLeftRadius="30dp"
android:topRightRadius="30dp"
android:topLeftRadius="30dp"/>
</shape>
create roundededittext.xml resource file in drawable folder, given below
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#eeCD3E22" />
<corners android:bottomRightRadius="30dp"
android:bottomLeftRadius="30dp"
android:topRightRadius="30dp"
android:topLeftRadius="30dp"/>
</shape>
Create your main xml layout file. I created with your custom edit text, shown here:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp">
<ImageButton
android:layout_width="50dp"
android:layout_height="50dp"
android:background="#drawable/roundedbutton"
android:elevation="10dp"
android:layout_gravity="center_vertical"
android:text="t"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginLeft="-30dp"
android:elevation="2dp"
android:layout_gravity="center_vertical"
android:background="#drawable/roundededittext"/>
</LinearLayout>
Hope it helps! Ask for any doubt.

Related

Custom floating action button

Help me please.
How can i do fab like this.
What i must use, that i can do this.
Maybe you know, that i can read about my problem?
Are there any samples / examples to perform such a transformation?
I tried using a background, but it's doesn't work
Problem in making this view.
FloatingActionButton hides all view on it. So your dot view can not be placed upon FAB. So we have to make ImageView instead of FAB.
Put this in your layout.
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:background="#drawable/blue_circle"
android:padding="15dp"
android:src="#mipmap/ic_launcher" />
<ImageView
android:layout_width="13dp"
android:layout_height="13dp"
android:layout_gravity="top|right"
android:src="#drawable/red_circle" />
</FrameLayout>
make new xml in res>drawable>blue_circle_gradient.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<gradient
android:endColor="#8e81fc"
android:startColor="#7264EA" />
</shape>
make new xml in res>drawable>red_circle.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="#ff0000" />
</shape>
Output will be same like this:

Two different pages get clipped with login and signUp page display in android xml layout

Login And SignUp Screen
How to implement and write xml file like this image? Please Help me.
I would suggest using Viewpager/Recyclerview,
I have used Recyclerview with the snap feature. My project requirement is, the next module button should be partially visible part of the first screen. So I have used recyclerview and kept the Item size bit smaller than screen width. So that the next item visible partially. As soon as clicking the button it will smoothscrool to next item.
Create layout like this,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="2"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.90"
android:orientation="vertical">
<!-- put your Login page content ,email
,password Edittext and other button here.
-->
</LinearLayout>
<LinearLayout
android:layout_width="40dp"
android:layout_height="match_parent"
android:layout_weight="0.10"
android:background="#drawable/lay_background"
android:weightSum="1">
<TextView
android:id="#+id/signUp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.10"
android:elevation="20dp"
android:gravity="center"
android:rotation="270"
android:text="Sign Up"
android:textAllCaps="true"
android:textColor="#ffffff"
android:textStyle="bold"
android:weightSum="1" />
</LinearLayout>
</LinearLayout>
lay_background.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="#color/colorAccent"/>
</shape>
</item>
<item
android:left="0dp"
android:right="0dp"
android:top="0dp"
android:bottom="2dp">
<shape android:shape="rectangle">
<solid android:color="#color/colorAccent"/>
<corners android:radius="5dp"/>
</shape>
</item>
</layer-list>
and onClick() of textview open your signup activity this is another approach.Try this I hope this will work for you.

Android - Draw a ribbon shape

I am trying not to use image view. This is because, later, I will generate many objects with the same shape but different colors, so I wouldn't need to keep adding image views but simply adding colors on my code.
How can I create those images on Android Studio? I looked over Paint, onDraw, Canvas, etc, but this looks difficult to me.
If you want to use from XML , Try this way it will work
<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="rectangle">
<size
android:width="100dp"
android:height="40dp" />
<solid android:color="#5EB888" />
<corners android:radius="0dp"/>
</shape>
</item>
<item
android:top="-26dp"
android:bottom="31dp"
android:left="-90dp"
android:right="75dp">
<rotate
android:fromDegrees="45">
<shape android:shape="rectangle">
<solid android:color="#ffffff" />
</shape>
</rotate>
</item>
</layer-list>
OUTPUT
You can create vector image using any vector program like Adobe Illustrator or convert it using a conversion tool like vectormagic or find already existing one then import it to android studio.
it will be imported as xml file where you can change the colors as you want
Create a drawable file as named left_arrow.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<rotate
android:fromDegrees="45"
android:toDegrees="90"
android:pivotX="0%"
android:pivotY="1%" >
<shape android:shape="rectangle" >
<stroke
android:width="10dp"
android:color="#00000000" />
<solid android:color="#ffffff" />
</shape>
</rotate>
</item>
Now, create a view layout to create this type of stripes or image like this, here is the below code:-
<?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:orientation="vertical">
<LinearLayout
android:id="#+id/llMain"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.1"
android:background="#color/black"
android:orientation="horizontal">
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.1"
android:background="#drawable/left_arrow"
android:contentDescription="#string/app_name" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.9"
android:contentDescription="#string/app_name" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.9" />
This above layout creates the required arrow stripe as a layout.
Now add this layout to your required layout where you wan't to show this stripes. For example,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="#+id/llMain"
layout="#layout/xtra"/>
</LinearLayout>
Now, you are able to also use OnClickListener by using "llMain".
Hope it will help.
You could use the white png image you already have and use the setColorFilter method on the image view class to tint it with any color you desire

Designing layout android

I am currently trying to create a list view which will show details about a post. For that, I have created xml file for designing the list item.
This is the final look I want for my activity. So far I have succeeded dealing with the rounded corners, image buttons and the texts, but I am trying for a while to deal with the left side of the text box. I want it to have a sharp tip. But I still can't handle it.
I will add the xml files to show what I did.
**This is the xml file for the list item**
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="300dp"
android:layout_height="160dp">
<LinearLayout android:id="#+id/desclayout"
android:layout_width="240dp"
android:layout_height="140dp"
android:background="#drawable/layout_my_posts_selector"
android:layout_marginRight="5dp">
<TextView
android:id="#+id/myPostDescription"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="left"
android:maxLength="120"
android:hint="#string/description"
android:inputType="textMultiLine"
android:lines="4"
android:maxLines="5"
android:paddingBottom="8dp"
android:textColorHint="#f7941e"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="8dp"
android:textColor="#6d6e71"
android:scrollbars="vertical"
android:textSize="14sp">
</TextView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_toRightOf="#+id/desclayout"
android:background="#drawable/description_layout_my_posts_selector"
android:orientation="vertical"
android:paddingLeft="7dp"
android:layout_height="140dp">
<ImageButton
android:id="#+id/acceptMyPostBtn"
android:layout_width="40dp"
android:background="#drawable/my_posts_button_selector"
android:layout_marginTop="5dp"
android:layout_height="40dp"
android:src="#drawable/v"/>
<ImageButton
android:id="#+id/closeMyPostBtn"
android:layout_width="40dp"
android:background="#drawable/my_posts_button_selector"
android:layout_below="#id/acceptMyPostBtn"
android:layout_height="40dp"
android:layout_marginTop="5dp"
android:src="#drawable/x"/>
<ImageButton
android:id="#+id/showOnMapMyPost"
android:layout_width="40dp"
android:src="#drawable/location"
android:background="#drawable/my_posts_button_selector"
android:layout_marginTop="5dp"
android:layout_height="40dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_below="#+id/desclayout"
android:paddingLeft="6dp"
android:background="#2d2d2d"
android:layout_height="20dp">
<TextView
android:layout_width="fill_parent"
android:textColor="#android:color/background_light"
android:text="Finished at 19/01/2013 13:55"
android:layout_height="fill_parent" />
</LinearLayout>
</RelativeLayout>
layout_my_posts_selector
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#f1f1f2"/>
<stroke android:width="3dp" android:color="#2d2d2d" />
<corners android:topLeftRadius="7dp" android:bottomLeftRadius="7dp"/>
<padding android:left="0dp" android:top="0dp" android:right="0dp" android:bottom="0dp" />
</shape>
description_layout_my_posts_selector
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#e7e8ea"/>
<stroke android:width="3dp" android:color="#2d2d2d" />
<corners android:topRightRadius="7dp" android:bottomRightRadius="7dp"/>
<padding android:left="0dp" android:top="0dp" android:right="0dp" android:bottom="0dp" />
</shape>
This is how it currently looks
If you can please guide me how to deal with the sharp tip I will be thankful!
While using a separate background xml file is a good idea, i would suggest that you use a drawable instead for background.
So you can design your background image with the 'sharp tip' on the left in photoshop or paint.net and set the property android:background=#drawable/background_design where 'background design' is the name of your design drawable file.
Programming it will take more resources to render the design. Not a good practice to use in a listview. For best performance go for a drawable for a static layout.
Well, I don't understand why my post have got -1,
but anyway I will post the way I chose to do it.
I have crated xml file named: triangle
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<rotate
android:fromDegrees="45"
android:pivotX="87%"
android:pivotY="115%"
android:toDegrees="45">
<shape android:shape="rectangle">
<solid android:color="#f1f1f2"/>
</shape>
</rotate>
</item>
</layer-list>
After this I have added linear layout to my list_item_xml with
the background of the triangle xml.
Thanks for your help, have a nice day
You can use 9 patch as a background.Create one here

Android creating Circular layout

I am trying to create a circular layout that always stay's on the screen.
To do so, I have created a System overlay and added a button.
But, now I want to make it round.
Either I can use 4 different ImageView and and textView and add both to FrameLayout.
I read somewhere that simple things like this can be made by XML.
How do I do it?
I want to achieve something like this :
EDIT
After following your guide I was able to achieve this :
But I am not satisfied by the way I used.
What I did was created 2 shaped (background, forground) and added them to a layerlist.
BACKGROUND
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval" >
<solid android:color="#50000000" />
</shape>
FORGROUND
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval" >
<solid android:color="#99009900" />
</shape>
LIST
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="#drawable/circleback">
</item>
<item
android:bottom="5dp"
android:drawable="#drawable/circlefront"
android:left="5dp"
android:right="5dp"
android:top="5dp">
</item>
</layer-list>
Then, I used a framelayout and added 2 textview.
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:background="#drawable/circle" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="33dp"
android:text="#string/data_left"
android:layout_marginTop="8dp"
android:textColor="#fff"
android:textSize="30sp"
android:typeface="sans"
android:textStyle="bold"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:text="#string/band"
android:layout_marginTop="40dp"
android:textColor="#fff"
android:textSize="20sp"/>
</FrameLayout>
And then inflated them by service. But I am not happy with the textposition and the fact that I have to random hit and trial to find center of circle.
I'll later add pinch to zoom to view so, I really want to find a way that text align itself to centre of circle.
You need to create a shape drawable (in the res/drawable folder) like:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval"
<solid android:color="#ff00ff00 />
</shape>
See docs: https://developer.android.com/guide/topics/resources/drawable-resource.html#Shape

Categories

Resources