I would like to follow material design guidelines in my application. For tappable text should I use unbounded or bounded surface ink ripples (displayed when the user presses on the text)?
I used this Custom ripple layout for myself, I think it is easy to use:
RippleLayout
and you can use it like this in your xml file:
<your.package.name.RippleLayout
android:layout_width="40dp"
android:layout_height="40dp"
app:mrl_rippleSelectedColorState="#android:color/transparent">
<!-- other views like buttons and.... -->
</your.package.name.RippleLayout>
Related
Is there a way to align the icon to the start, top, and left of the material button in android XML? Do it programmatically is also acceptable.
I would expect app:iconPadding="0dp" to do that, but it doesn't. The goal is something like this:
My XML:
<com.google.android.material.button.MaterialButton
android:id="#+id/return_button"
app:cornerRadius="40dp"
app:icon="#drawable/icon_back"
app:iconPadding="0dp"
app:iconGravity="start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="RETURN" />
No. There are guidelines that comes with Material Widgets. If you want to do something like this you should find another ways like drawing on canvas, compound views, libraries.
I would like to create this component as a custom component in Android:
I shall use it like:
<MyEditText android:layout_width="match_parent"
android:layout_height="wrap_content"
label="ART" />
And like the regular EditText, when focus is on, borders and label become blue, like in the image, when focus is off, label and borders become grey.
Is it possible to create a component as described above?
The button has is set in the activity's XML layout with:
<Button
android:id="#+id/dummy_button"
style="?buttonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/dummy_button" />
The part to pay attention to is style="?buttonBarButtonStyle". The definition for the queried style is defined in styles.xml as:
<style name="ButtonBarButton" />
The style doesn't actually set any values for the button and so I can't understand why I would change anything about the button and the way it displays.
When the button is set to use the empty style, it looks like this:
But when the line style="?buttonBarButtonStyle" is removed, it looks like a standard button like this:
At first I thought that assigning the empty style would replace the default style settings for a button, but trying this in my own app doesn't change the appearance of a button at all (as I would have expected an empty style to do).
Can anybody work out exactly why this empty style is changing the look? To replicate this yourself you can create a new app using the "Fullscreen Activity".
Your ButtonBarButton and buttonBarButtonStyle has no relation to each other. You apply buttonBarButtonStyle style which is a theme attribute and defines some style for a bar button. If you can to apply your custom empty style to a button use:
style="#style/ButtonBarButton"
I'm not sure what it is that is surprising to you. The usual look of buttons is the one in the second image, so when the style is applied, that inside rectangle is removed which is a custom look. If you have seen buttons without any custom styling you would have seen that they look like the one in the second image.
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 testmail#gmail.com"
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!
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).
Firstly, for the mail icon you would need a LeftAligned ImageView
with appropriate dimensions.
Next up we have a Bold TextView containing the text "Email1".
This is followed by another 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)
Finally we have an indicator image, which again can be an 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
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.
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
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 TextViews and ImageViews inside that.
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.
I would like my app to have a day of week selector with multiple day selection capability. I'm using ToggleButtons for this right now, but because of the indicator lights a ToggleButton takes too much space on the screen. Without the lights, my ToggleButtons would look like normal (toggleable) Buttons and they could fit in one row. How can I hide the lights?
The answer is this part:
android:background="#android:drawable/btn_default"
For example, following will make the light disappear and toggle button would look like a default button, but with the toggle functionality:
<ToggleButton android:id="#+id/your_btn"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textOn="On" android:textOff="Off"
android:background="#android:drawable/btn_default" />
You can use a custom android:background drawable for them, that will override the graphics including the indicator light. If you look at Android: using framework drawables in custom button selector, there's instructions for copying resources from the SDK to your own project. You presumably could copy the platform normal button drawable and use that as your background.