android-relativelayout

ImageView adjustViewBounds not working with Relative Layout

拈花ヽ惹草 提交于 2020-01-01 09:22:35
问题 I have an ImageView and have set its layout_height to "100dp" and its layout_width to "wrap_content". The drawable used has bigger actual dimensions that are 130dp (width) X 215dp (height). When the ImageView is placed inside a LinearLayout , if I set adjustViewBounds to true, it gets a width that is measured according to the drawable's aspect ratio and the layout_width. However, when placed inside a RelativeLayout the ImageView gets the same width as the drawable (130dp), no matter the

Android: Using alignBaseline for an image following text

怎甘沉沦 提交于 2020-01-01 04:19:08
问题 Below is a TextView followed by an ImageView contained in RelativeLayout. I'm trying to get the bottom of the image to align with the baseline of the text. When I use alignBaseline for the image,reference the TextView, it is the top of the image that aligns with the baseline of the text instead of the bottom. How can I fix this? <TextView android:id="@+id/month" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:text="feb"

Issue with RelativeLayout when View visibility is View.GONE

 ̄綄美尐妖づ 提交于 2019-12-31 10:56:38
问题 I've a RelativeLayout thus: <RelativeLayout> <TextView1/> <TextView2/> // <-- View.VISIBLE OR View.GONE <TextView3/> <TextView4/> </RelativeLayout> Each TextView is anchored below the previous TextView with android:layout_below . The problem is that TextView2 may or may not be there (either View.VISIBLE or View.GONE ); if it's View.VISIBLE , then all is fine, but if it's View.GONE , then TextView3 ends up being rendered on top of TextView1. I've tried various ways to fix this, but each time

Scale background image to wrap content of layout

只谈情不闲聊 提交于 2019-12-29 11:46:18
问题 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="

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

元气小坏坏 提交于 2019-12-27 12:51:23
问题 Is it possible when creating a RelativeLayout at runtime to set the equivalent of android:layout_below programmatically? 回答1: 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

How to fill all space in parent Relative layout?

妖精的绣舞 提交于 2019-12-25 07:32:32
问题 I created a small example to explain my problem. In the example I created a RelativeLayout that fills the whole screen. And 3 children : FrameLayout with id middle that must fill all empty space without overlay on top and bottom of FrameLayout (pink) FrameLayout with id top that must show above middle (red) FrameLayout with id bottom that must show below middle (yellow) layout: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

Overlapping in RelativeLayout

安稳与你 提交于 2019-12-25 04:49:15
问题 I have one RelativeLayout which contains 2 linearlayouts, one should always be aligned with bottom (for log out purpose.) and the other starts from top and contains 2 viewstubs. These two viewstubs have different heights any only one of them will be visible at same time. My problem is if I make top linearlayout align top and bottom linearlayout align bottom, contents overlap if viewstubs height is bigger. I can not make them above and below of any as if the viewstubs height is smaller views

Android Admob ad not shown in Activity with fragment. Why?

做~自己de王妃 提交于 2019-12-25 03:36:23
问题 I have an activity as follows. I launch it inside another activity using setContentView(R.layout.below); However, below.xml contains a pager (which is a fragment and has its own textview, webview etc.). My problem is even though the Google Ads block is shown in the graphical layout on Eclipse and NO error is thrown when I run the java code shown below; I CAN NOT see the ad. I don't understand what is happening! I've tried so many things, including changing this layout to a simple relative

Android: RelativeLayout margin works but gets overridden

前提是你 提交于 2019-12-25 01:46:49
问题 Problem Using RelativeLayout.LayoutParams and marginTop before setLayoutParams( params ) . Works on all devices for half a second but some cases it bumps back to top. The view stays centered in the holding view on my Moto X 2014 running Lollipop but not on my Nexus 4 running Lollipop . Opening activity Opens activity The margin is fine and the SurfaceView is centered ~200ms delay The margin resets and its back to top (top of SurfaceView at the top of holder) Closing activity Back pressed

How to put ImageView over RelativeLayout?

强颜欢笑 提交于 2019-12-25 01:27:51
问题 I'm designing a Profile Layout. For which I'm using Imageview and RelativeLayout. I'm trying put ImageView on top of RelativeLayout.I used both elevation and android:scaleType="centerCrop" but it shows okay in the design editor but when I compile and run app then ImageView always stays behind the RelativeLayout. In Design Editor it shows Which is what I want but in the device, it shows like this Please help.. Below is my XML File <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns