android-relativelayout

How to get RelativeLayout working with merge and include?

我与影子孤独终老i 提交于 2019-11-26 15:03:54
问题 I have been trying for a few days now to make my layouts more efficient by converting from using several levels of nested LinearLayouts to one RelativeLayout and have come across a few problems that I haven not been able to find a workaround for... I have searched the Android beginners group and this site and have not been able to find anything that would help me solve the problem. I read on one of the blogs that you can combine layouts with merge and include tags. So what I have is a main

How do I programmatically remove an existing rule that was defined in XML?

 ̄綄美尐妖づ 提交于 2019-11-26 13:22:03
问题 I have a linear layout that is contained inside a relative layout. It is set in the XML file to be to the right of another linear layout (this works fine). In some cases I want to change the relative position of the layout during the onCreate of the activity so I need to modify the "to the right of" param to relate to another layout. I tryed this: RelativeLayout.LayoutParams layoutParams; layoutParams = (RelativeLayout.LayoutParams) linearLayoutToMove .getLayoutParams(); layoutParams.addRule

How to set RelativeLayout layout params in code not in xml?

 ̄綄美尐妖づ 提交于 2019-11-26 12:11:39
For example I want to add 3 buttons on screen: one align left, one align center, last one align right. How can I set their layout in code, not in xml ? Just a basic example: RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); Button button1; button1.setLayoutParams(params); params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); params.addRule

Is a RelativeLayout more expensive than a LinearLayout?

冷暖自知 提交于 2019-11-26 11:11:40
I've always been using RelativeLayout everytime I needed a View container, because of it's flexibility, even if I just wanted to display something really simple. Is it ok to do so, or should I try using a LinearLayout when I can, from a performance/good practices standpoint? Thanks! In a talk at Google I/O 2013 (Writing Custom Views for Android), Romain Guy clarified the misunderstanding that caused everyone to start using RelativeLayouts for everything. A RelativeLayout always has to do two measure passes. Overall it is negligible as long as your view hierarchy is simple. But if your

Circular dependencies cannot exist in RelativeLayout, android?

对着背影说爱祢 提交于 2019-11-26 08:20:37
问题 I have the following layout: I need to keep the button at the bottom of screen and it should be visible to the user. The rest of the layout should scroll. <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:paddingBottom=\"@dimen/activity_vertical_margin\" android:paddingLeft=\"@dimen/activity_horizontal_margin\" android:paddingRight=\"

Extending RelativeLayout, and overriding dispatchDraw() to create a zoomable ViewGroup

孤人 提交于 2019-11-26 07:59:20
问题 I\'ve seen a few people ask how to zoom an entire ViewGroup (such as a RelativeLayout) in one go. At the moment this is something I need to achieve. The most obvious approach, to me, would be to hold the zoom scale factor as a single variable somewhere; and in each of the child Views\' onDraw() methods, that scale factor would be applied to the Canvas prior to graphics being drawn. However, before doing that, I have tried to be clever (ha - usually a bad idea) and extend RelativeLayout, into

What are the differences between LinearLayout, RelativeLayout, and AbsoluteLayout?

时光怂恿深爱的人放手 提交于 2019-11-26 06:04:09
问题 I am confused about the difference between LinearLayout, RelativeLayout, and AbsoluteLayout. Could someone please tell me the exact differences between them? 回答1: LinearLayout means you can align views one by one (vertically/ horizontally). RelativeLayout means based on relation of views from its parents and other views. ConstraintLayout is similar to a RelativeLayout in that it uses relations to position and size widgets, but has additional flexibility and is easier to use in the Layout

How to programmatically set the layout_align_parent_right attribute of a Button in Relative Layout?

萝らか妹 提交于 2019-11-26 05:52:46
问题 I have a relative layout which I am creating programmatically: RelativeLayout layout = new RelativeLayout( this ); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); Now I have two buttons which I want to add in this relative layout. But the problem is both buttons are being shown on the left of the RelatiiveLayout overlapping on each other. buttonContainer.addView(btn1); buttonContainer.addView(btn2); Now I want to know

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

二次信任 提交于 2019-11-26 04:56:00
问题 I am trying to add Fancycoverflow in my app,It works fine with static image as given in this example. but i did some changes in Adapter, and i try to run my app and it crashes and shows following error FATAL EXCEPTION: main java.lang.ClassCastException: android.view.ViewGroup$LayoutParams cannot be cast to android.widget.Gallery$LayoutParams at android.widget.Gallery.setUpChild(Gallery.java:889) at android.widget.Gallery.makeAndAddView(Gallery.java:858) at android.widget.Gallery.layout

Overlapping Views in Android

别等时光非礼了梦想. 提交于 2019-11-26 04:11:30
问题 Is it possible to have overlapping views in Android? I would like to have an ImageView with a transparent png in the front and another view in the background. edit: This is what I have at the moment, the problem is that the image in the imageView is not transparent, the parts that should be transparent are just black. <RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\" android:orientation=\"vertical\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap