android-relativelayout

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

冷暖自知 提交于 2019-12-22 04:26:12
问题 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 Relative Layout alignParentRight and alignParentEnd

爷,独闯天下 提交于 2019-12-21 05:06:11
问题 I'm trying to figure out the difference between the layout params for relative layout, specifically alignParentRight and alignParentEnd (also alignParentLeft and alignParentStart). Reading the reference doesn't help much, I figured the end of a parent was always its right. Is there any difference to this? Is one depreciated now? 回答1: I figured the end of a parent was always its right Only for left-to-right (LTR) languages. For right-to-left (RTL) languages (e.g., Hebrew, Arabic), end is left

Android Relative Layout Align Center

跟風遠走 提交于 2019-12-20 10:59:24
问题 I am trying to create a List Activities Item Layout as follows <?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"> <ImageView android:contentDescription="ss" android:id="@+id/place_category_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingRight="15dp" android:paddingTop="10dp" android:src="@drawable/marker"/>

Setting up RelativeLayout in java code

余生长醉 提交于 2019-12-19 06:24:10
问题 I'm having a hard time getting two text views to appear on top of each other in my java code. Here's the code I'm experimenting with: /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); layout = new RelativeLayout(this); text1 = new TextView(this); text1.setText("1"); text2 = new TextView(this); text2.setText("2"); RelativeLayout.LayoutParams p = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams

match_parent property for children in a RelativeLayout

女生的网名这么多〃 提交于 2019-12-18 11:19:13
问题 In short, is it possible to tell a child in a RelativeLayout to always match the height of that RelativeLayout regardless of how other children in that same RelativeLayout behave? In short, that's it. Details below. What I'm trying to achieve is a ListView row with at least three views, and one of those views would be kind of a stripe at the right side of the list entry (the red view below). The problem I'm having is that there is a TextView at the left side, and depeding on how much text I

RelativeLayout add rule “RelativeLayout.LEFT_OF” not working

三世轮回 提交于 2019-12-18 04:34:15
问题 I have a relativeLayout like below: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal" android:id="@+id/parent" > <ListView android:layout_width="360dp" android:layout_height="600dp" android:id="@+id/list" android:inputType="text" android:maxLines="1" android:layout_margin="50dp" android:layout_alignParentRight="true" /> </RelativeLayout> In the java code, I want to

Android: RelativeLayout in ScrollView

拜拜、爱过 提交于 2019-12-17 15:49:08
问题 I have a RelativeLayout with multiple ImageView s and when I turn around the screen, the ImageView s become disordered. So I decided to wrap it into a ScrollView . But the ScrollView doesn't work! Can any one help me with that? I know that the right way is to design a GridView or ListView , but since I had some questions and no one answered me, I decided to go this way. Here is my xml code : <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res

Android: 2 relative layout divided in half screen

六月ゝ 毕业季﹏ 提交于 2019-12-17 15:22:32
问题 I tried many times to draw 2 Relative layout aligned horizontally and divided in half screen. I design the image with paint to explain a bit better what i mean. Any suggestion? 回答1: You can put these 2 RelativeLayouts inside a LinearLayout with horizontal orientation, then use the weight for both RelativeLayouts. This will divide the LinearLayout in 2 equal parts. <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" android

How to create a RelativeLayout programmatically with two buttons one on top of the other?

一曲冷凌霜 提交于 2019-12-17 03:53:42
问题 I'm adding two buttons to the UI, but they appear on top of one another. I want them to appear next to each other. What am I missing in this code? 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

Create a new TextView programmatically then display it below another TextView

女生的网名这么多〃 提交于 2019-12-17 03:09:47
问题 String[] textArray={"one","two","asdasasdf asdf dsdaa"}; int length=textArray.length; RelativeLayout layout = new RelativeLayout(this); RelativeLayout.LayoutParams relativeParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); for(int i=0;i<length;i++){ TextView tv=new TextView(getApplicationContext()); tv.setText(textArray[i]); relativeParams.addRule(RelativeLayout.BELOW, tv.getId()); layout.addView(tv, relativeParams); } I need to do something like