android-relativelayout

How to design spannable gridview using recyclerview (SpannableGridLayoutManager)

旧城冷巷雨未停 提交于 2019-11-28 06:18:22
问题 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

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

戏子无情 提交于 2019-11-28 04:23:36
问题 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

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

给你一囗甜甜゛ 提交于 2019-11-28 03:10:38
问题 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. 回答1: Try this @Override public void

Android RelativeLayout programmatically Set “centerInParent”

筅森魡賤 提交于 2019-11-28 03:05:05
I have a RelativeLayout like this: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="10dip"> <Button android:id="@+id/negativeButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="20dip" android:textColor="#ffffff" android:layout_alignParentLeft="true" android:background="@drawable/black_menu_button" android:layout_marginLeft="5dip" android:layout_centerVertical="true" android:layout

Android GLSurfaceView transparent background without setZOrderonTop

浪尽此生 提交于 2019-11-27 23:35:55
问题 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

How do I set background image with picasso in code

丶灬走出姿态 提交于 2019-11-27 21:55:34
I know picasso loads image into imageview etc but how do I set my layout background image using picasso? My code: public class MainActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); RelativeLayout relativeLayout = (RelativeLayout) findViewById(R.id.relativelayout); relativeLayout.setBackgroundResource(R.drawable.table_background); Picasso.with(MainActivity.this) .load(R.drawable.table_background) .resize(200, 200) .into(relativeLayout); return relativeLayout; } What I

ImageView fills parent's width OR height, but maintains aspect ratio

╄→гoц情女王★ 提交于 2019-11-27 18:20:21
I have a square image (though this problem also applies to rectangular images). I want to display the image as large as possible, stretching them if necessary, to fill their parents, while still maintaining the aspect ratio. The image is smaller than the ImageView. The problem is, I can't stretch the image and "match" the height and width of the ImageView. This is my XML layout file: <?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="wrap_content" android:padding="10dp">

Android: 2 relative layout divided in half screen

空扰寡人 提交于 2019-11-27 17:23:49
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? 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:baselineAligned="false"> <RelativeLayout android:layout_width="0dp" android:layout_height="wrap_content"

How to put RelativeLayout inside CoordinatorLayout

蹲街弑〆低调 提交于 2019-11-27 14:36:16
问题 I'm trying to recreate the search box as it is in Airbnb Android app. So I'm using CoorinatorLayout with Toolbar and RecyclerView . But when I insert something inside the Coordinator besides those two things, it doesn't show up. Here is my code: <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/slidingLayout" android:layout_width="match_parent" android:layout_height=

Accessing attrs in AttributeSet for custom components

杀马特。学长 韩版系。学妹 提交于 2019-11-27 13:35:30
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 the technique to do this with custom attributes, but what if I want to grab an attribute that's already