android-relativelayout

How to give layout weight in RelativeLayout?

落爺英雄遲暮 提交于 2019-12-06 15:37:33
I have created a dialpad using LinearLayout . Here is the code <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:gravity="center" android:orientation="vertical"> <TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap

Responsive layout on Android

你。 提交于 2019-12-06 15:36:50
I have three elements in layout, two TextViews and one ImageView between them. I'm trying to achieve this behavior: image (arrow) has 9patch image is wide as possible image has set minimal width right and left texts go wider with longer text but only to meet image's minWidth, then new line appears Below are few screenshots from Android Studio layout preview, gained with different layouts. What I have tried: Relative layout: image centered, minWidth set, texts have set toRightOf/toLeftOf Relative layout: image has set toRightOf/toLeftOf Constraint layout: "constraint arrows" go from image to

Aligning images about right bottom corner

£可爱£侵袭症+ 提交于 2019-12-05 20:20:30
I am using relative layout to superimpose one smaller image on top of a larger one. I want the bottom-right corner of the smaller image to coincide with B-R corner of the larger image. I'm using margin parameters in my layout XML (specifying measurement in dips) but this doesn't seem to work for all devices and resolutions - in some cases the small image is shifted by 4-5px from the border. Is it possible to specify the position of the smaller image without pixel values? I.e. with gravity or something? <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout

how to half overlap imageview on another imageview in android

自闭症网瘾萝莉.ら 提交于 2019-12-05 06:40:13
how can I overlap images half on one another from layout XML file like this image. Simply you can use RealtiveLayout and negative margins <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/activity_landing" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/screen_background"> <ImageView android:background="@color/black" android:id="@+id/img_background" android:layout_width="match_parent" android:layout_height="wrap_content" android:src="@mipmap/ic_launcher" />

java.lang.ClassCastException: android.view.ViewGroup$LayoutParams cannot be cast to android.widget.RelativeLayout$LayoutParams

爱⌒轻易说出口 提交于 2019-12-05 03:23:24
I've just edited my XML, I've put slide menu code in my XML, but there is an error. <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#ffffff" > <ListView android:id="@+id/menu_content_menulist" android:layout_width="match_parent" android:layout_height="match_parent" android:padding="8dp" android:cacheColorHint="@android:color/transparent" android:divider="@null" android:listSelector="@null"/>

How do I enforce a circular reference in a RelativeLayout?

我们两清 提交于 2019-12-05 01:17:32
I have two widgets within a RelativeLayout that must reference each other. Technically it is not a circular reference since the widget A is vertically aligned with widget B and widget B is horizontally aligned with widget A. Here is my code (condensed): <Button android:id="@+id/btnLanguageFrom" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" android:layout_toLeftOf="@id/imgArrow" android:text="English" /> <ImageView android:id="@+id/imgArrow" android:layout_width="wrap_content" android:layout

Android ScrollView fillViewport not working

为君一笑 提交于 2019-12-05 00:31:40
I have a simple layout with a name on the top, and a button which I want to be at the bottom of the screen, or beyond that in case I add more items. So I am using a ScrollView with a LinearLayout as follows: <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/white" android:fillViewport="true" android:focusableInTouchMode="true" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity

Android RelativeLayout Selector state_pressed doesn't work

给你一囗甜甜゛ 提交于 2019-12-04 23:21:15
I have RelativeLayout like this: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout android:id="@+id/contacts" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_weight="0.2" android:layout_width="wrap_content" android:layout_height="wrap_content"> <ImageView android:id="@+id/image" android:layout_width="wrap_content" android:layout_height="wrap_content" android:adjustViewBounds="true" android:contentDescription="@string/content_description_contacts" android:scaleType="fitXY" android:src="@drawable/contacts" /> <TextView android:id="@+id/text" android:layout_width=

Android relative layout align parent right

≯℡__Kan透↙ 提交于 2019-12-04 22:51:31
I have following layout: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/test_ll" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/background" android:orientation="vertical" > <RelativeLayout android:id="@+id/main_layPanelCircle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical|center_horizontal" android:layout_marginLeft="10dp" android:layout

how to put a border around an android relativelayout?

南笙酒味 提交于 2019-12-04 22:44:42
I've seen this subject about puting a border around an android textview, and I used it. But now, I would like to put a border around widgets which are situated into a relative layout. How can I do it? in your res/drawable folder, create a new file background_border.xml In this file, you will define the background for widget like this: <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <!-- This is the stroke you want to define --> <stroke android:width="1dp" android:color="@color/color_stroke"/> <!-- Optional, round your corners --> <corners android