android-layout

What about percentage usage?

放肆的年华 提交于 2021-02-08 03:45:30
问题 So, i'm thinking about the usage of percent, example, in margins. We can use overlay to separate our layout by dpi sizes, but why can't we use percentage? Something like that: Display display = getWindowManager().getDefaultDisplay(); float width = display.getWidth(); float height = display.getHeight(); //20% of left margin float imageMarginLeft = ( width * 20 ) / 100; And then set this margin to the image, or whatever element. Is this bad? I just wanna discuss about it. Thanks. 回答1:

Dismiss a bottom sheet dialogue in android from its own Custom Activity

。_饼干妹妹 提交于 2021-02-08 03:00:58
问题 I have created a custom bottom sheet android dialogue with the help of this answer by Chintan Khetiya:How to create a Custom Dialog box in android?. I want to dismiss the dialogue from the button defined in the BottomDialogue's own Activity.Not from Calling activity. Here is my code in the Calling activity in which i have created my custom BottomSheet_liab instance by click of a button: openBottomDialogeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View

Dismiss a bottom sheet dialogue in android from its own Custom Activity

╄→尐↘猪︶ㄣ 提交于 2021-02-08 03:00:10
问题 I have created a custom bottom sheet android dialogue with the help of this answer by Chintan Khetiya:How to create a Custom Dialog box in android?. I want to dismiss the dialogue from the button defined in the BottomDialogue's own Activity.Not from Calling activity. Here is my code in the Calling activity in which i have created my custom BottomSheet_liab instance by click of a button: openBottomDialogeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View

Why doesn't setEnabled(false) trigger a ColorStateList for theme Theme.AppCompat.Light?

你。 提交于 2021-02-08 01:18:59
问题 I am trying to use setEnabled(false) on a Button to show grey disabled state... I can only get the desired result if I force a theme on the button with android:theme="@style/Button" and then change the parent on that Button style to something other than the Theme.AppCompat.Light.DarkActionBar , such as from Material: <style name="Button" parent="android:Theme.Material.Light.NoActionBar"> (even then, only the button background changes, the text color doesn't.) I can't see the Button as grey

Why doesn't setEnabled(false) trigger a ColorStateList for theme Theme.AppCompat.Light?

折月煮酒 提交于 2021-02-08 01:18:12
问题 I am trying to use setEnabled(false) on a Button to show grey disabled state... I can only get the desired result if I force a theme on the button with android:theme="@style/Button" and then change the parent on that Button style to something other than the Theme.AppCompat.Light.DarkActionBar , such as from Material: <style name="Button" parent="android:Theme.Material.Light.NoActionBar"> (even then, only the button background changes, the text color doesn't.) I can't see the Button as grey

How to make seat booking layout like redbus

徘徊边缘 提交于 2021-02-07 20:35:21
问题 I am working on a bus booking app and I want to add seat booking layout like in the Red Bus App. I design layout using GridView but it looks like What I have What I want I need less space between Seat 1 and Seat 2 then big space between Seat 2 and 3 and again space between seat 3 and seat 4 as seat 1 and 2. And in last row i need 5 seats. I need exactly same as red bus layout. XML <RelativeLayout android:id="@+id/seatLayoutLowerMain" android:layout_width="wrap_content" android:layout_height=

support.v7 ShareActionProvider crashes if showAsAction=“always”

女生的网名这么多〃 提交于 2021-02-07 20:24:04
问题 Trying to use ShareActionProvider from the support library (v7), my app works fine if I don't set the showAsAction attribute for the menu item. My intention is to display this menu item as an icon and not as an overflow item. If, however, I set it to show always, the app crashes with NullPointerException . 07-30 01:23:37.778: E/AndroidRuntime(25853): java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ImageView.setImageDrawable(android.graphics.drawable

How to set width and track text in a Switch/SwitchCompat button and achieve this result? (Image and GIF attached)

这一生的挚爱 提交于 2021-02-07 19:22:36
问题 I need to implement a button in my app like this I used a SwitchCompat button but the closest I arrived was to this point, having two main problems: 1 - The width of the button does not adjust correctly when screen sizes change (drawable gets cut off, become too small etc), it is important that the width occupies the parent view correctly ( a small linear layout enclosing it) 2 - I was not able to understand how I could get the letters in the Switch Track Is it possible to achieve this result

TextView as a progressbar with textcolor minipulation?

♀尐吖头ヾ 提交于 2021-02-07 18:16:59
问题 I'm working on improving my app's UI. And in the design I'm using I have a TextView that will act as a progress bar at certain time. The ruslt should look like this : The thing is that parts of text will change their color while the progress is changing I looked into spannablestring in android it would work if I can find the letters that are covered by the progress ( but I don't think this would be easy/accurate) What I'm planning todo now is to use the following: FrameLayout with :

TextView as a progressbar with textcolor minipulation?

时光毁灭记忆、已成空白 提交于 2021-02-07 18:14:54
问题 I'm working on improving my app's UI. And in the design I'm using I have a TextView that will act as a progress bar at certain time. The ruslt should look like this : The thing is that parts of text will change their color while the progress is changing I looked into spannablestring in android it would work if I can find the letters that are covered by the progress ( but I don't think this would be easy/accurate) What I'm planning todo now is to use the following: FrameLayout with :