android-relativelayout

Circular dependencies cannot exist in RelativeLayout, android?

Deadly 提交于 2019-11-26 22:32:40
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="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.vfc

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

半世苍凉 提交于 2019-11-26 21:35:47
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 a class called ZoomableRelativeLayout. My idea is that any scale transformation could be applied just

Can I Set “android:layout_below” at Runtime Programmatically?

与世无争的帅哥 提交于 2019-11-26 19:33:56
Is it possible when creating a RelativeLayout at runtime to set the equivalent of android:layout_below programmatically? Rich Schuler Yes: RelativeLayout.LayoutParams params= new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.BELOW, R.id.below_id); viewToLayout.setLayoutParams(params); First, the code creates a new layout params by specifying the height and width. The addRule method adds the equivalent of the xml properly android:layout_below . Then you just call View#setLayoutParams on the view you want to

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

空扰寡人 提交于 2019-11-26 16:54:51
I am confused about the difference between LinearLayout, RelativeLayout, and AbsoluteLayout. Could someone please tell me the exact differences between them? 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 Editor. WebView to load html, static or dynamic pages. FrameLayout to load child one above another, like cards

Accessing attrs in AttributeSet for custom components

我是研究僧i 提交于 2019-11-26 16:24:51
问题 I've got a custom component containing two TextViews that have a custom size-setting method on (the two text views are proportional by about a 1:2 ratio). Being that this is a subclass of RelativeLayout, it doesn't have a textSize attribute, but I'm wondering if it is possible to still set the android:textSize attribute in the XML instantiation for this component, and then grab the textSize attribute from the AttributeSet to use with my custom setSize() method in the constructor. I've seen

Create a new TextView programmatically then display it below another TextView

点点圈 提交于 2019-11-26 16:15:34
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 that.. so it would display as one two asdfasdfsomething on the screen.. If it's not important to use a

How to add a view programmatically to RelativeLayout?

给你一囗甜甜゛ 提交于 2019-11-26 15:44:20
问题 Can you give me a very simple example of adding child view programmatically to RelativeLayout at a given position? For example, to reflect the following XML: <?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"> <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true"

Differences between ConstraintLayout and RelativeLayout

安稳与你 提交于 2019-11-26 15:38:50
I am confused about the difference between ConstraintLayout and RelativeLayout . Could someone please tell me the exact differences between them? Intention of ConstraintLayout is to optimize and flatten the view hierarchy of your layouts by applying some rules to each view to avoid nesting. Rules remind you of RelativeLayout , for example setting the left to the left of some other view. app:layout_constraintBottom_toBottomOf="@+id/view1" Unlike RelativeLayout , ConstraintLayout offers bias value that is used to position a view in terms of 0% and 100% horizontal and vertical offset relative to

How to switch from the default ConstraintLayout to RelativeLayout in Android Studio

允我心安 提交于 2019-11-26 15:19:53
问题 I have the latest android Studio (2.3 beta 3) and it seems ConstraintLayout is the default when creating a project. How can I make Android Studio use the RelativeLayout as the default layout element for new projects ? 回答1: Well, I saw the answer above and it worked for me too. But, I gave it a shot, and succeded converting my current project to Relative Layout. Do as follows: At activity_main.xml tab, change it to text. At the top of it, you'll find the following: <android.support.constraint

Overlapping Views in Android

心不动则不痛 提交于 2019-11-26 15:07:25
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_content" android:id="@+id/gallerylayout" > <Gallery android:id="@+id/overview" android:layout_width="fill