relativelayout

Relative Layout: Different behavior on Api < 11

耗尽温柔 提交于 2019-12-21 05:05:51
问题 I don't know why, but layout is shown well on device with Api 11+, isn't for older. This is xml: <LinearLayout android:id="@+id/workers_linearlayout" android:layout_width="50dp" android:layout_height="70dp" android:layout_weight="1" > <RelativeLayout android:id="@+id/workers_relative_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" > <ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap

Android - Two buttons in same line filling the whole width

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-20 12:36:38
问题 I have a little problem defining a Relative Layout. I have a List View with scroll and two buttons always visible at the bottom of the list view. I just would like my two button have 50% of the width, filling the line. This is my code: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <Button android:id="@+id/testbutton"

A view does not show inside a relative layout

我们两清 提交于 2019-12-20 07:56:20
问题 I have a problem with this layout and i cannot find out what is wrong. As you can see, there is a chronometer and a table inside a relative layout but the chronometer does not show, not even a blank space. <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/firstLayout" android:layout_width="fill_parent" android:layout_height="fill_parent" > <Chronometer android:id="@+id/chrono" android:textColor="#4169E1" android

Android_RelativeLayout - How to put two elements on the same line?

只谈情不闲聊 提交于 2019-12-20 04:33:24
问题 The question is: I have a TextView and an EditText, how can I place them on the same "level"? http://postimage.org/image/o9l17a3zv/ As you can see, I want to put "Username" on the same level of the EditText... Here my code: <TextView android:id="@+id/account_creation" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/account_creation" android:textSize="20sp" android:textStyle="bold" /> <!-- Username --> <TextView android:id="@+id/username

android dynamically add layouts under each other

谁说胖子不能爱 提交于 2019-12-19 04:15:18
问题 I'm trying to add multiple layouts dynamically under each other. So I wrote the following code: for (int i = 1; i <= layoutCounter; i++) { View neu = inflater.inflate(R.layout.vote, parent, false); neu.setId(layoutID); if (layoutID == 1) { params = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.BELOW, R.id.txtMultiline); } else { params = new RelativeLayout.LayoutParams( RelativeLayout

Adjust width to half screen

风流意气都作罢 提交于 2019-12-19 02:39:11
问题 I came across this link : Assign width to half available screen width declaratively How to do the same in relative layout? Here's the code: Trying linearlayout inside relative layout. But this doesn't work. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/bg" > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent"

ImageView won't fill parent

 ̄綄美尐妖づ 提交于 2019-12-19 01:37:19
问题 I have a ScrollView on one of my screens. I want the right edge to have a shadow. I decided the easiest way to do this was to make the child of the ScrollView a RelativeLayout, and have two children of the RelativeLayout -- one being a LinearLayout that will house the layout of the screen, and the second View being the shadow. Like so... <ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent" android:scrollbars="none" > <RelativeLayout android:layout_width="fill

ImageView won't fill parent

风格不统一 提交于 2019-12-19 01:36:50
问题 I have a ScrollView on one of my screens. I want the right edge to have a shadow. I decided the easiest way to do this was to make the child of the ScrollView a RelativeLayout, and have two children of the RelativeLayout -- one being a LinearLayout that will house the layout of the screen, and the second View being the shadow. Like so... <ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent" android:scrollbars="none" > <RelativeLayout android:layout_width="fill

Dynamic Grid Layout

主宰稳场 提交于 2019-12-18 05:24:08
问题 I want to implement grid, which will be populated dynamically. I want to know what is the best approach to implement this Relative layout(List View) or Grid Layout? 回答1: You can generate a GridView dynamically. GridView would contain of ImageView and TextView as per your need. You will have to use your custom adapter. In it's getView method, populate the ImageView and TextView. Example: GridView item.xml: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout

Android - How do I specify weight programmatically for a RelativeLayout?

て烟熏妆下的殇ゞ 提交于 2019-12-18 03:39:12
问题 I want to do something like this programmatically - <LinearLayout> <RelativeLayout1 weight = 1> <RelativeLayout2 weight = 3> <RelativeLayout3 weight = 1> <LinearLayout> It does not let me do a setWeight programmatically. However, I do see that RelativeLayout has an android:layout_weight parameter in XML. Am I missing something? 回答1: When you add the RelativeLayout to the LinearLayout using addView you have to provide a LinearLayout.LayoutParams, something like this : LinearLayout.LayoutParams