android-layout

Changing app locale sometimes doesn't change direction of layouts

泪湿孤枕 提交于 2020-07-23 07:32:08
问题 I'm changing locale of my app programmatically using the following method. It works fine but when I start an already existing singleTask activity using Intent.FLAG_ACTIVITY_CLEAR_TOP flag. Then application loses the layout direction but translation is correct. For example, if application language is Arabic then all views direction is changed to English locale (left-to-right). What could be the reason? I'm calling following method in attachBaseContext of BaseActivity and Application class.

Floating Action Button appearing as a square

北慕城南 提交于 2020-07-22 21:35:23
问题 I am currently working on an Android app and using the latest addition of the Floating Action Button. However, after compiling the necessary libraries and adding the fab into my xml file, it appears as a square while I am expecting it to be a circle, just like everywhere else. I use the same basic code to implement the fab as found online and my result is a square and theirs is a nice circle fab. Here is my code: <android.support.design.widget.FloatingActionButton android:id="@+id/fab"

Rendering Problems The following classes could not be found: android.support.constraint.ConstraintLayout

不问归期 提交于 2020-07-22 07:08:06
问题 I have added ConstraintLayout 1.0.0 to my project as a dependency and it builds successfully. But in Android Studio 2.2 in activity_main.xml in Design tab I always receive this message: Rendering Problems The following classes could not be found: - android.support.constraint.ConstraintLayout ( Add constraint-layout library dependency to the project, Fix Build Path, Edit XML, Create Class) Tip: Try to build the project. Tip: Try to refresh the layout. Because of that visual editor doesn't

ListView inside constraint view gets clipped and not scrolling

两盒软妹~` 提交于 2020-07-21 06:34:26
问题 I have a listview inside my ConstraintLayout and I read its supposed to automatically be scrollable, but the list just gets cut-off at the bottom with more items left to be displayed and its not scrollable, I dont know if Im setting some atribute wrong or if I have to add something for listview to scroll?? Here is my code <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas

AndroidX Preference Screen shifted off center [duplicate]

為{幸葍}努か 提交于 2020-07-18 07:21:28
问题 This question already has answers here : Android: How to remove margin/padding in Preference Screen (17 answers) Closed 12 months ago . I have a preference screen in my app and it is shifted off center and the header text or data doesn't start from the left shown in the image below. I am initializing the settings fragment. I have not applied any visual changes or added any special attributes. There is no padding or margin in the parent activity. I also have a recycler view which is displayed

How to create a circular outlined Material Button in Android?

折月煮酒 提交于 2020-07-18 04:25:58
问题 I am trying to create a button with an icon in the center. The top and bottom part of the circle are a little flat. Is there a way to do this without using corner radius? Here is my layout for the button. <com.google.android.material.button.MaterialButton android:id="@+id/start_dispenser_btn" style="@style/Widget.MaterialComponents.Button.OutlinedButton" android:layout_width="175dp" android:layout_height="175dp" android:padding="14dp" app:cornerRadius="150dp" app:icon="@drawable/ic_play_arrow

Is there any event fired when android View becomes visible within App?

牧云@^-^@ 提交于 2020-07-18 03:37:29
问题 My App contains multiple views (scrollable), one of them is CustomView ( extends View), is there any android event fired when this View comes within visible area. The approach i though of using background thread during the timeframe of onAttachedToWindow to onDetachedToWindow This thread will use customView.getGlobalVisibleRect(rectangle) to check whether any portion of the view is visible on the screen but this is spin lock approach, Is there any better way to detect visibility, any event

Is there any event fired when android View becomes visible within App?

不羁的心 提交于 2020-07-18 03:37:18
问题 My App contains multiple views (scrollable), one of them is CustomView ( extends View), is there any android event fired when this View comes within visible area. The approach i though of using background thread during the timeframe of onAttachedToWindow to onDetachedToWindow This thread will use customView.getGlobalVisibleRect(rectangle) to check whether any portion of the view is visible on the screen but this is spin lock approach, Is there any better way to detect visibility, any event

What is android:layout_marginStart

家住魔仙堡 提交于 2020-07-17 09:49:22
问题 I would like to add some space between the left display border and an ImageView. Android SDK made me aware of "android:layout_marginStart". Consider adding android:layout_marginStart="10dp" to better support right-to-left layouts Why should I use android:layout_marginStart="10dp" instead of android:layout_marginLeft="10dp" ? I have never done so and never encountered any problems with so-called "right-to-left layouts". 回答1: start and end are the same as left and right for left-to-right (LTR)

animateLayoutChanges=“true” in BottomSheetView showing unexpected behaviour

ε祈祈猫儿з 提交于 2020-07-16 16:32:17
问题 I have a BottomSheetView which has animateLayoutChanges="true" . Initially it shows up fine. But if change the visibility of a view (inside BottomSheetView ) from GONE to VISIBLE , the app messes up calculations and my BottomSheetView moves to the top of the screen. i have tried setting layout_gravity=bottom at the root of the BottomSheetView layout. But no success. Here I have the image of my BottomSheetView before changing the visibility of any view. (Click image for full size) After I