Reputation: 5618
On an iOS App I saw such a Button:
The same I would like to do in Android, how could I achieve this? What I tried is the following code:
<Button
android:id="@+id/widget41"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:text="Email1 [email protected]"
android:textStyle="bold" />
Looks something like that:
Well just a normal (ugly looking) Button. I have no idea, how I could style it like in iOS. Any suggestions or links would be appreciated!
Upvotes: 0
Views: 1929
Reputation: 66
Here is a tutorial for creating stylized android buttons. You can round the corners and change the background colors to look like the buttons in ios.
Here is a similar question.
Hope this helps.
Upvotes: -1
Reputation: 5266
The best solution would be to create your own custom view that behaves like the iOS counterpart (though, as other users have mentioned, Android does have it's own design guidelines, and the view that you are seeing is an iOS implementation that is designed for that platform).
If you look at the iOS image above (a copy of yours with some parts highlighted), I have split it up into sections.
You could use an Android ViewGroup
like a LinearLayout
to create the overall image, and give the LinearLayout
a border or background (which can be a bitmap image of a rounded rectangle for example (See Android Nine Patch for an example of how to make this fit multiple screens).
LeftAligned ImageView
with appropriate dimensions.Bold TextView
containing the text "Email1".TextView
which is blue and uses the
elipsize
property (as defined in an Android XML layout) to create
"..."
at the end once the text has reached the max width it can
consume. (Use android:ellipsize="end"
in the XML)ImageView
sized appropriately.You could also achieve this with a RelativeLayout
, which would allow you to RightAlign
the indicator image, LeftAlign
the mail icon, and allow the text to fill the space in between that it can get hold of.
Example of Nine Patch use for the background here
Upvotes: 4
Reputation: 15414
Well, as others have clearly mentioned there is no default Button in Android like this, and for your info neither is in iOS. Its all about the design. Anything is possible, in the end it all comes to how far are you willing to go to achieve it.
Below is a simple code, that will be close to your design.
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_margin="5dp"
android:background="@drawable/text_background"
android:drawableLeft="@drawable/envelope"
android:drawablePadding="10dp"
android:drawableRight="@drawable/right_arrow"
android:ellipsize="end"
android:gravity="center_vertical"
android:text="@string/email" />
There can be other ways also, like that whole view could be a ViewGroup, either a LinearLayout
or a RelativeLayout
and there could be multiple TextView
s and ImageView
s inside that.
Upvotes: 0
Reputation: 2947
You should design your own button to looks like iOS one.
Android has it own design guidelines:
http://developer.android.com/design/patterns/pure-android.html
Upvotes: 0
Reputation: 5869
That is UITableView
in iOS(just like ListView
in android). It depends on the list item design you do it. There is no such Button
Control in Android.
Upvotes: 0