android-relativelayout

Android RelativeLayout align center of one view on top right corner of another view

a 夏天 提交于 2019-11-30 12:43:55
问题 I have experience with RelativeLayout but I've never run across a way to solve the problem I am presented with (aside from hard coding margin values, which I want to avoid.) I want to try to create something like the following image in a RelativeLayout: The box is its own View and I want to get the View that contains the orange circle to be centered on the top right corner of the View that contains the blue box. I tried with android:alignTop="boxView" and android:alignRight="boxView" but that

RelativeLayout Scrollable

扶醉桌前 提交于 2019-11-30 07:27:20
问题 I have tried many times to aligh the elements in my RelativeLayout but I dont get the result I expected that is: I'd like to align the first button to top right and then I have multiple Textview and I want all of them Scrollable, but when I insert the tag I get an error, this is my code: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/RL01" android:layout_width="fill_parent" android:layout_height="fill_parent"

Android RelativeLayout align center of one view on top right corner of another view

ε祈祈猫儿з 提交于 2019-11-30 02:58:07
I have experience with RelativeLayout but I've never run across a way to solve the problem I am presented with (aside from hard coding margin values, which I want to avoid.) I want to try to create something like the following image in a RelativeLayout: The box is its own View and I want to get the View that contains the orange circle to be centered on the top right corner of the View that contains the blue box. I tried with android:alignTop="boxView" and android:alignRight="boxView" but that put my orange circle completely within my box. I want it to be so that the circle is centered above

TextView color change on focus/press

好久不见. 提交于 2019-11-30 02:56:23
问题 I have a some ui widgets including textview inside RelativeLayout which is clickable. My problem is textview text color does not change when relativelayout gets focus although I have set textview color property correctly. Is there any easy way to cascade focus to childview inside relative layout, same as listview items. <RelativeLayout android:id="@+id/top_layout" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:background="

PercentRelativeLayout, how to set the height programmatically

萝らか妹 提交于 2019-11-30 02:55:00
I am using PercentRelativeLayout from android percent support package. this is what I have in my layout. <android.support.percent.PercentRelativeLayout android:id="@+id/view_parent" app:layout_heightPercent="68%" android:visibility="invisible" android:layout_width="match_parent" android:background="@color/mountain_meadow" android:layout_alignParentTop="true" android:layout_height="wrap_content"> <View android:id="@+id/view_child" android:layout_width="match_parent" app:layout_heightPercent="30%" android:layout_alignParentBottom="true" /> </android.support.percent.PercentRelativeLayout> I want

OnClickListener doesn't work with clickable attribute

半腔热情 提交于 2019-11-30 02:01:20
问题 So, my problem is that OnClickListener doesn't work when I set android:clickable="true" into my class. This is MyClass xml code: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/background" android:clickable="true"> ... ... </RelativeLayout> MyClass.java: public class MyClass extends RelativeLayout implements OnClickListener { public MyClass(Context context) { super

Android: Setting Background Image for RelativeLayout?

情到浓时终转凉″ 提交于 2019-11-30 01:49:49
问题 I have downloaded an image at runtime. Now I want to set it as a background for RelativeLayout . Does it possible? 回答1: Check out the setBackgroundDrawable, or maybe createFromPath in the Drawable class. RelativeLayout rLayout = (RelativeLayout) findViewById (R.id.rLayout); Resources res = getResources(); //resource handle Drawable drawable = res.getDrawable(R.drawable.newImage); //new Image that was added to the res folder rLayout.setBackground(drawable); 回答2: Instead use: View lay = (View)

FrameLayout to RelativeLayout ClassCastException even if there is no FrameLayout used

此生再无相见时 提交于 2019-11-30 00:47:41
问题 In my application, I have a layout which has a RelativeLayout to which I want to set margins at runtime programmatically. But when I do that, it gives me ClassCastException saying FrameLayout can not cast to RelativeLayout . I don't have any FrameLayout used, also there are no imports for FrameLayout . Still the problem persists. The xml I am using is: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/rl_root"

Expand TextView with wrap_content until the neighbor view reaches the end of the parent

杀马特。学长 韩版系。学妹 提交于 2019-11-30 00:01:49
I need to achieve the following layout: I have two TextViews in a relative layout: the green one is fixed text with wrap_content , the black one has dynamic text with wrap_content . The black text can change and become very long. I want the black TextView to expand with the text until the green view reaches the end of the parent. If that happens, the black TextView should stop expanding and ellipsize the end. How can I achieve that? What I tried: <RelativeLayout android:id="@+id/parent" android:layout_width="match_parent" android:layout_height="wrap_content" > <TextView android:id="@+id

FrameLayout vs RelativeLayout for overlays

故事扮演 提交于 2019-11-29 22:47:12
I need to implement an overlay (translucent) screen for my app, something similar to Showcase View My guess was to use FrameLayout for this usecase, because it is used to stack items on top of each other. But I was surprised to see that the above library uses RelativeLayout . My question is when to use FrameLayout then, if not in cases like this? What are the disadvantages if I go the FrameLayout way? A common rule of thumb when choosing layouts is to select the combination that results in the smallest number of nested layout views. Specific to your question, RelativeLayout is larger and more