android-relativelayout

Create a new TextView programmatically then display it below another TextView

妖精的绣舞 提交于 2019-12-17 03:09:05
问题 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

What does Relative layout wrap_content do?

混江龙づ霸主 提交于 2019-12-14 01:13:08
问题 I have a simple layout as follows. Even though, I set all attributes as wrap_content, the resulting layout fills the entire screen height wise. The individual layouts in themselves are small. So the top level container should only be as big as to wrap all its elements. But it seems to fill the full screen. Width wise, the same attributes work fine. What am I missing here? <RelativeLayout android:id="@+id/topcontainer" android:layout_width="wrap_content" android:layout_height="wrap_content"

how to get view's position in coordinates?

限于喜欢 提交于 2019-12-13 14:27:10
问题 Hi I have an ImageView inside RelativeLayout, now how can I get X and Y position of imageview on screen ? I have tried getLocationOnScreen log(mPhoto.getLeft()); log(mPhoto.getScrollX()); log(mPhoto.getX()); log(mPhoto.getTranslationX()); but all of them returns 0. Above functions are called after progmatically setting imageview to center RelativeLayout.LayoutParams lp1 = new RelativeLayout.LayoutParams(mFaceWidth, mFaceHeight); lp1.addRule(RelativeLayout.CENTER_HORIZONTAL); lp1.addRule

Unexpected namespace prefix “app” found for tag RelativeLayout - Android?

本秂侑毒 提交于 2019-12-13 11:59:11
问题 I need to use BottomSheetBehavior with ScrollView but it says to me : Unexpected namespace prefix "app" found for tag RelativeLayout app:behavior_hideable="true" app:behavior_peekHeight="80dp" Here is my xml : <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent">

Why do I get white space on top and on the bottom of my ImageView in my RelativeLayout?

梦想与她 提交于 2019-12-13 11:35:53
问题 I am using a relativelayout to overlay to images. On all screen sizes so far that I have tested (from 2.7 to 10.1 inch) I always get white space on top of my image. In my IDE I always see that my relativelayout is causing the extra space on top and on the bottom of my image. Why is that? I have set all height attributes to wrap_content and even added the adjustViewBounds attribute. Note: You should know that my image is a lot bigger in size, meaning that there will be some sort of scaling.

Android border bottom for custom view not working

不羁的心 提交于 2019-12-13 07:43:50
问题 What I'm trying to do is to have a relativelayout with a gradient on it and a gray bottom border, I'm using the below custom view in my application: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/list_item_container" android:layout_width="match_parent" android:layout_height="wrap_content" > <ImageView android:id="@+id/list_item_image" android:layout_width="match_parent" android:layout_height="@dimen/SIZE_LIST

Relative layout - stick buttons to bottom

淺唱寂寞╮ 提交于 2019-12-13 06:58:09
问题 I have a relative layout with two sub relative layouts: The first sub layout contains two text views, the second sub relative layout is below the first sub relative layout. However when I design all looks fine. When rendered on phone the buttons don't align to the second sub relative layouts bottom. Here is my code: <RelativeLayout android:id="@+id/relative_txt" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_alignBottom="@+id/relative_img" android

CoordinatorLayout / RelativeLayout issue within a ViewSwitcher

荒凉一梦 提交于 2019-12-13 02:14:57
问题 This is a follow up question of this one: Coordinator Layout and Relative Layout issue I have an issue when you have a CoordinatorLayout with a RelativeLayout within a ViewSwitcher like the following example: <?xml version="1.0" encoding="utf-8"?> <ViewSwitcher xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/switcher"> <!--First switcher view / Splash Screen--> <RelativeLayout android:layout

Align Button and EditText on Relative Layout

心不动则不痛 提交于 2019-12-13 00:25:14
问题 I have this code as the footer of my listview. Its just an EditText and a Button to send messages. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:orientation="vertical" android:layout_height="fill_parent" android:id="@+id/relativelayout_messages" android:gravity="right" android:background="@drawable/fondomain" android:paddingTop="4dp"> <ListView android:id="@+id/android:list" android:listSelector="@android:color

How to keep Android Layout consistent across various devices?

别说谁变了你拦得住时间么 提交于 2019-12-12 22:31:06
问题 I am new to Android Programming, I just published an app on playstore and found out that few buttons that I put in my layout doesn't show up on some of the devices. How do I make sure it is consistent across various devices? Should I avoid using relative layout. Here is the layout where Create Account Button shows up on Galaxy Tab, Nexus 4, and 5 but not on Galaxy Grand. <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android