我有一个RelativeLayout因此: <RelativeLayout> <TextView1/> <TextView2/> // <– View.VISIBLE OR View.GONE <TextView3/> <TextView4/> </RelativeLayout> 每个TextView都使用android:layout_below固定在以前的TextView下面。 问题是,TextView2可能会或可能不会在那里( View.VISIBLE或View.GONE ); 如果它是View.VISIBLE ,那么一切都很好,但如果它是View.GONE ,那么TextView3最终将被渲染在TextView1之上。 我已经尝试了各种方法来解决这个问题,但是每次我都被RelativeLayout ''定义'规则之前不能引用一个id'。 我希望我在这里错过了一些明显的东西。
在API 17之前,如何从布局中删除规则? 我有一个RelativeLayout与一些孩子。 RelativeLayout是我的活动的主要布局。 以编程方式添加规则后使用 RelativeLayout.LayoutParams layout = (LayoutParams) theChild.getLayoutParams(); layout.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); 我需要稍后以编程方式删除规则。 我会如何做这个假设比17更早的API?
当在相对布局的上下文中使用时,“基线”是指什么? 简单的问题,可能,但文档和谷歌提供没有提示。
Android中的RelativeLayout比LinearLayout有什么优势? 对于一个你更喜欢的特定devise,背后的原因是什么? 它是(RelativeLayout)相似或类似的HTML <div> ?
我一直在浏览很多谷歌的结果/问题,以确定如何通过垂直animation显示/隐藏视图,但我似乎无法find一个完全正确或不太模糊的。 我有一个布局(撤消栏),在另一个布局下面,并在其他多个小部件之上; 此撤消栏应根据具体情况垂直滑动打开并滑动closures。 目前我所做的只是将视图设置为可见或不可见。 请帮忙。
我有一个像这样的相关布局: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="10dip"> <Button android:id="@+id/negativeButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="20dip" android:textColor="#ffffff" android:layout_alignParentLeft="true" android:background="@drawable/black_menu_button" android:layout_marginLeft="5dip" android:layout_centerVertical="true" android:layout_centerHorizontal="true"/> <Button android:id="@+id/positiveButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="20dip" android:textColor="#ffffff" android:layout_alignParentRight="true" android:background="@drawable/blue_menu_button" android:layout_marginRight="5dip" android:layout_centerVertical="true" android:layout_centerHorizontal="true"/> </RelativeLayout> 我希望能够编程设置为positiveButton相同的效果: android:layout_centerInParent="true" 我怎样才能编程?
是否有可能在运行时创build相对布局,以编程方式设置等效的android:layout_below ?
我有3个问题: imageView(白色瓷砖)比gridView中的其他瓷砖显得大得多(这很奇怪,因为它只设置为5dp x 5dp) 在我的editText上设置android:layout_alignParentRight =“true”,textView和imageView似乎不会将图像移动到右侧 android:layout_below =“@ id / sqwhite”似乎不把我的editText放在我的textView下 (基本上来说:我需要在右下angular正确设置这些尺寸,但是我所用的参数都没有任何影响。) 有任何想法吗? <?xml version="1.0" encoding="utf-8"?> <com.example.project.DragLayer xmlns:android="http://schemas.android.com/apk/res/android" xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher" android:id="@+id/drag_layer" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@android:color/black" > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:weightSum="1.0" > <GridView android:id="@+id/image_grid_view" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="0.8" android:background="@color/grid_background" android:gravity="center" android:horizontalSpacing="2dip" android:numColumns="@integer/num_columns" android:stretchMode="columnWidth" android:verticalSpacing="2dip" /> <RelativeLayout android:id="@+id/bottom_part" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_centerHorizontal="true" android:layout_weight="0.2" android:background="@android:color/black" […]
我在UI中添加了两个button,但它们显示在另一个上面。 我希望他们出现在彼此旁边。 我在这段代码中错过了什么? m_btnCrown = new ImageButton(this); m_btnCrown.setImageResource(R.drawable.king_crown_thumb); m_btnCrown.setAlpha(100); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); lp.addRule(RelativeLayout.ALIGN_PARENT_TOP); addContentView(m_btnCrown, lp); m_btnMonkey = new ImageButton(this); m_btnMonkey.setImageResource(R.drawable.monkey_small); m_btnMonkey.setAlpha(100); lp = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); lp.addRule(RelativeLayout.ALIGN_PARENT_TOP); lp.addRule(RelativeLayout.RIGHT_OF, m_btnCrown.getId()); addContentView(m_btnMonkey, lp);
我有一个相对的布局,我正在编程创build: RelativeLayout layout = new RelativeLayout( this ); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); 现在我有两个button,我想添加在这个相对的布局。 但问题是两个button都显示在RelatiiveLayout左侧相互重叠。 buttonContainer.addView(btn1); buttonContainer.addView(btn2); 现在我想知道如何以编程方式设置android:layout_alignParentRight="true的android:layout_alignParentRight="true ”或android:layout_toLeftOf="@id/btn"属性,就像我们在xml中一样?