android-layout

Repeatedly altering visibility of a child view and measuring parent view causes wrong results in measured size and display

此生再无相见时 提交于 2020-04-10 18:09:52
问题 Why is it that when you repeatedly alter the visibility of a child view that is contained within a parent view and measure the parent view, Android returns wrong results? I created a simple test: an XML file with only one ConstraintLayout and two TextViews. I will repeatedly alter the visibility of the last TextView to GONE and VISIBLE. Each time I alter the visibility of the TextView, I will measure the ConstraintLayout's width and height. To alter the visibility of the TextView, I set a

ListView.getCheckedItemPositions not able to return checked Items in SparseBooleanArray

半城伤御伤魂 提交于 2020-04-10 18:09:30
问题 I m trying to read the contacts in a list with multiple checkboxes , but when i call the sparsebooleanarray ..it just return false for all the list entries,..even for the one s checked ...I looked into this thread Why is ListView.getCheckedItemPositions() not returning correct values? ...But when i implement the addClickHandlerToCheckBox it force stops..this has been bugging me for 4 days..please any help.. public void populateContactList() { // Build adapter with contact entries final Cursor

Right to left menu items Android

雨燕双飞 提交于 2020-04-10 15:13:10
问题 I have an Slide menu as picture one. And i need to align its items title to be right to left like slide two . I tried gravity=right but didn't work. Here is my code : <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:gravity="end" android:layout_gravity="end"> <group android:checkableBehavior="single" android:layout_gravity="end" android:gravity="end"> <item android:id="@+id/nav_1" android:icon="@drawable/ic_keyboard

Right to left menu items Android

给你一囗甜甜゛ 提交于 2020-04-10 15:08:23
问题 I have an Slide menu as picture one. And i need to align its items title to be right to left like slide two . I tried gravity=right but didn't work. Here is my code : <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:gravity="end" android:layout_gravity="end"> <group android:checkableBehavior="single" android:layout_gravity="end" android:gravity="end"> <item android:id="@+id/nav_1" android:icon="@drawable/ic_keyboard

MotionLayout with vertical ScrollView

旧巷老猫 提交于 2020-04-10 14:01:45
问题 I'm trying to make animation with motion layout, and want to set scrollView as targetAnchor for motion scene onSwipe Transition, but it doesn't work. Maybe I don't know some thing about onSwipe transition. Here is my layout file <androidx.constraintlayout.motion.widget.MotionLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color

Changing Toolbar and CollapsingToolbarLayout scroll flags programmatically

≯℡__Kan透↙ 提交于 2020-04-09 08:53:35
问题 I have a single Activity android app with lots of fragments. When I'm showing a list screen I want to use the Toolbar with the, app:layout_scrollFlags="scroll|enterAlways" property. And in the detail fragments I want to use the CollapsingToolbarLayout with an image in it. Since it's a single Activity app, I have only one Toolbar . Is it possible to modify my layout programmatically to suit both cases? 回答1: Yes. Let's say you are going from the CollapsingToolbarLayout fragment to the Toolbar

Changing Toolbar and CollapsingToolbarLayout scroll flags programmatically

允我心安 提交于 2020-04-09 08:49:01
问题 I have a single Activity android app with lots of fragments. When I'm showing a list screen I want to use the Toolbar with the, app:layout_scrollFlags="scroll|enterAlways" property. And in the detail fragments I want to use the CollapsingToolbarLayout with an image in it. Since it's a single Activity app, I have only one Toolbar . Is it possible to modify my layout programmatically to suit both cases? 回答1: Yes. Let's say you are going from the CollapsingToolbarLayout fragment to the Toolbar

Changing Toolbar and CollapsingToolbarLayout scroll flags programmatically

安稳与你 提交于 2020-04-09 08:48:28
问题 I have a single Activity android app with lots of fragments. When I'm showing a list screen I want to use the Toolbar with the, app:layout_scrollFlags="scroll|enterAlways" property. And in the detail fragments I want to use the CollapsingToolbarLayout with an image in it. Since it's a single Activity app, I have only one Toolbar . Is it possible to modify my layout programmatically to suit both cases? 回答1: Yes. Let's say you are going from the CollapsingToolbarLayout fragment to the Toolbar

Changing Toolbar and CollapsingToolbarLayout scroll flags programmatically

房东的猫 提交于 2020-04-09 08:42:51
问题 I have a single Activity android app with lots of fragments. When I'm showing a list screen I want to use the Toolbar with the, app:layout_scrollFlags="scroll|enterAlways" property. And in the detail fragments I want to use the CollapsingToolbarLayout with an image in it. Since it's a single Activity app, I have only one Toolbar . Is it possible to modify my layout programmatically to suit both cases? 回答1: Yes. Let's say you are going from the CollapsingToolbarLayout fragment to the Toolbar

How to make a drawable Shape programmatically (Android)

柔情痞子 提交于 2020-04-08 14:42:30
问题 i'm making a custom TextView (Java class) and i'm having trouble "to translate" the line (on "original TextView" xml) android:background="@drawable/myDrawableShape" to a java void to change the color of the "myDrawableShape" myDrawableShape.xml <shape xmlns:android="http://schemas.android.com/apk/res/android" > <solid android:color="#ffafafaf" /> <corners android:radius="15dp" /> I'll get the color to set from a String, the void to change the color programmatically could be (for example) void