android-relativelayout

Scale background image to wrap content of layout

北战南征 提交于 2019-11-29 21:22:58
I have a layout that contains some text fields and has a background image that's displayed at the top of my activity. I'd like the background image to scale to wrap the content (don't care about aspect ratio). However, the image is larger than content, so the layout instead wraps the background image. Here's my original code: <RelativeLayout android:layout_width="fill_parent" android:id="@+id/HeaderList" android:layout_gravity="top" android:layout_height="wrap_content" android:background="@drawable/header"> <TextView android:layout_height="wrap_content" android:layout_width="wrap_content"

How to avoid overlap view in relative layout in android?

夙愿已清 提交于 2019-11-29 20:36:23
<ScrollView 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:orientation="vertical" > <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" > <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" android:textSize="30sp" /> <TextView android:id="@+id/textView2" android:layout_width="wrap_content

Marshmallow RelativeLayout behaves strange with alignBaseline

馋奶兔 提交于 2019-11-29 18:18:37
问题 On Android 6.0 Marshmallow the positioning of an EditText in relation to an ImageView in a RelativeLayout with the attributes baseline and layout_alignBaseline does not work anymore. The behaviour can even be observed in the layout editor in Android studio. On a real Android Marshmallow device or emulatr the EditText in my case is shift outside the screen and not visible. Do I miss some changes, is it a bug? <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns

How to get programmatically width and height of Relative - Linear layout in android?

亡梦爱人 提交于 2019-11-29 13:17:07
I required runtime dimensions of Relative/Linear Layout. activity_home.xml : <RelativeLayout android:id="@+id/rlParent" android:layout_width="match_parent" android:layout_height="match_parent" > </RelativeLayout> HomeActivity.java: private int width, height; RelativeLayout rlParent = (RelativeLayout) findViewById(R.id.rlParent); w = rlParent.getWidth(); h = rlParent.getHeight(); Log.i("Width-Height", width+"-"+height); Please share your thoughts. user2511882 Try this @Override public void onWindowFocusChanged(boolean hasFocus) { // TODO Auto-generated method stub super.onWindowFocusChanged

How to design spannable gridview using recyclerview (SpannableGridLayoutManager)

与世无争的帅哥 提交于 2019-11-29 13:04:33
I want to design grid view like below image provided. The first item should be bigger than the rest. Currently I am using RelativeLayout with GridLayoutManager check below code RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view1); RecyclerView.LayoutManager recyclerViewLayoutManager = new GridLayoutManager(context, 3); recyclerView.setLayoutManager(recyclerViewLayoutManager); recyclerView_Adapter = new RecyclerViewAdapter(context,numbers); recyclerView.setAdapter(recyclerView_Adapter); Dummy array for demo String[] numbers = { "one", "two", "three", "four", "five", "six

How do I vertically align an item within a list using relative layout?

江枫思渺然 提交于 2019-11-29 10:42:24
I am using a list view in Android 1.5 to show a list of images and text next to the image. I am trying to vertically center the text but the text is at the top of the row instead of centered. Below is my layout: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/row" android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="10dip"> <ImageView android:id="@+id/item_image" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingRight="10dip" android:src="

Android GLSurfaceView transparent background without setZOrderonTop

假如想象 提交于 2019-11-29 06:09:38
Sorry for my English. My work is based on https://github.com/harism/android_page_curl/ After many hours of research, I have found a few solutions, but not for all the issues what I have in my application. I've some trouble with a GLSurfaceView. I've got a background with a relativeLayout, a GLSurfaceView, and an overlay on top. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/background" android:layout_width="match_parent" android:background="@layout/backgroundrepeat" android:layout_height="match_parent"> <com.m2y.foxprez.view.CurlView xmlns:android=

RelativeLayout add rule “RelativeLayout.LEFT_OF” not working

女生的网名这么多〃 提交于 2019-11-29 05:47:42
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 add a view to the left of the listview, but it didn't worked: m_relativeLayout = (RelativeLayout

RelativeLayout Scrollable

 ̄綄美尐妖づ 提交于 2019-11-29 03:41:50
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:orientation="vertical" android:padding="5dp"> <ScrollView android:layout_width="fill_parent"

PercentRelativeLayout, how to set the height programmatically

元气小坏坏 提交于 2019-11-28 23:50:17
问题 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=