relativelayout

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

…衆ロ難τιáo~ 提交于 2019-12-18 03:39:05
问题 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

Android - set layout background programmatically

佐手、 提交于 2019-12-17 18:56:18
问题 I have noticed that the setBackground method for the RelativeLayout object is targeted for API 16 (Android 4.1) and higher, but my application has the target API 8 and I cannot use it. Is there any alternative solution for this problem (besides marking the class/method with TargetApi (16) or changing the target API in the manifest)? Thank you! Edit : Eclipse was buggy and it showed me the same error for setBackgroundDrawable but now it seems to work. Thank you for your help. 回答1: Use one of:

Android XML Layout Parameters Do Not Function As Expected

限于喜欢 提交于 2019-12-17 05:15:58
问题 I have 3 issues: The imageView (of a white tile) appears MUCH larger than the other tiles in the gridView (which is strange because it's only set to 5dp x 5dp) setting android:layout_alignParentRight="true" on my editText, textView and imageView do not seem to move the image to the right android:layout_below="@id/sqwhite" does not seem to place my editText under my textView (Basically: I need to get these to be sized correctly in the bottom right hand corner but none of the parameters I've

Centering the Matrix of ImageViews to the Center of the Screen Dynamically

爷,独闯天下 提交于 2019-12-14 03:34:15
问题 This is my Layout File: RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/imageLayout" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:layout_gravity="center" android:background="@color/silver"> <TextView android:id="@+id/bottom" android:layout_width="match_parent" android:layout_height="50dp" android:layout_alignParentBottom="true" android:layout

How to make every content of a Relative Layout clickable in android

女生的网名这么多〃 提交于 2019-12-14 03:33:41
问题 I have a layout: <RelativeLayout android:layout_width="match_parent" android:layout_height="227dp" android:addStatesFromChildren="true" android:clickable="true" android:duplicateParentState="false" android:focusable="true" android:id ="@+id/relLay"> <Gallery android:id = "@+id/gvImage" android:layout_height="200dp" android:layout_width="match_parent" android:paddingRight="5dp" android:paddingLeft="5dp" android:fadingEdgeLength="2dp" android:clickable="true"/> <TextView android:clickable="true

Equal Button Widths In A View

爱⌒轻易说出口 提交于 2019-12-13 17:54:26
问题 I'm not doing too bad with layouts at the moment but there is just one piece I can't seem to do with ease. Imagine if you will two, or three buttons next to each other and I want them all to be the same size (width) relative to the width of the screen. e.g if the screen was 300 pixels each one would be 100 pixels wide (Assuming there is no boarder etc). A good example of this would be in Excel, I would select three columns next to each other and hit "Distribute cell widths evenly" So, my

How to align a TextView to the right of another TextView which breaks to the next line?

梦想与她 提交于 2019-12-13 16:03:13
问题 The problem I am having is aligning the second TextView to the right of the TextView which spans to two lines. I am using a RelativeLayout , but when I use layout_toRightOf it appears at the top of the screen, and when I add layout_alignRight it disappears. I am very confused how this works. You would assume that it would follow where the first TextView ends, but it does not. Oh, and I am using wrap_content on width and height incase anyone thinks that's the problem. Thanks in advance. XML

RelativeLayout inside of ScrollView - Android

杀马特。学长 韩版系。学妹 提交于 2019-12-13 09:46:50
问题 I am changing my whole layout for this activity from a TableLayout to RelativeLayout for various reasons. I have 10 "rows" I want inside of this RelativeLayout but right now I am just trying to get one row working. After that 1 row is working, I will implement the other 9. There are 4 columns in each row and right now only the first column is displaying and not the last 3. Below is the code and screenshot. The "red x" is the first column that is displaying. <LinearLayout xmlns:android="http:/

layered images plus canvas

不打扰是莪最后的温柔 提交于 2019-12-13 05:44:21
问题 I am trying to lay two picture on top of each other. Top one is transparent. On top of them I am trying to add a transparent canvas so the user can draw, type, whatever they need to do and the bottom two images are visible. So I can get the two images to show up or just the canvas. Everytime I try to display the canvas it seems like it is on to[p of the two images covering them. Here is what I have so far.. public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

RelativeLayout with buttons

♀尐吖头ヾ 提交于 2019-12-13 04:43:54
问题 I want to add number of buttons to RelativeLayout dynamically, but my code doesn't work. It adds them to the same place on the display. private void createButtons() { buttons = new ArrayList<Button>(); RelativeLayout bg = (RelativeLayout) findViewById(R.id.Bg); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); for(int i = 0; i < channels.size(); i++){ Button newButton = new Button(this);