Questions tagged [android-percentrelativelayout]

Subclass of RelativeLayout that supports percentage based dimensions and margins. You can specify dimension or a margin of child by using attributes with "Percent" suffix. The tag is to be used with the [android] tag.

Subclass of RelativeLayout () that supports percentage based dimensions and margins. You can specify dimension or a margin of child by using attributes with "Percent" suffix.

Usage:

Please, use the tag jointly with tag.

Example:

<android.support.percent.PercentRelativeLayout
        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"/>
    <ImageView
        app:layout_widthPercent="50%"
        app:layout_heightPercent="50%"
        app:layout_marginTopPercent="25%"
        app:layout_marginLeftPercent="25%"/>
</android.support.percent.PercentFrameLayout/>

It is not necessary to specify layout_width/height if you specify layout_widthPercent. However, if you want the view to be able to take up more space than what percentage value permits, you can add layout_width/height="wrap_content". In that case, if the percentage size is too small for the View's content, it will be resized using wrap_content rule.

From PercentRelativeLayout:

This class was deprecated in API level 26.1.0.
consider using ConstraintLayout and associated layouts instead.

49 questions
1
vote
4 answers

How to make Percent dynamic in PercentRelativeLayout?

I am using PercentRelativeLayout from Design Support Library and i want to set different Percentage for 7 inch and 10 inch tablet. For example if i have ImageView like below.
Pranav
  • 4,172
  • 3
  • 30
  • 31
1
vote
1 answer

Controlling nested ViewGroup size in a RelativeLayout: with wrap_content is still matching parent

I have a widget that uses PercentRelativeLayout to position 4 ImageViews inside it. I need the percent feature because I’m putting the images along the 4 sides of the box but with different relative sizes: the top child takes up ~60 percent of the…
1
vote
1 answer

Android PercentRelativeLayout width and height should be specified

I'm trying to use android.support.percent.PercentRelativeLayout:
1
vote
4 answers

how to align a view below centered in parent view in a relative layout

I want to align a Framelayout below a view which has centerInParent attribute set to true in a relative layout. I've tried layout_below but it doesn't work. then I tried to remove centerInParent and tried center_horizontal and center_vertical but it…
1
vote
1 answer

Android PercentRelativeLayout width won't change with ratio when layout changed

I'm trying to make a textureview keep the 16:9 ratio when layout changes. I use percentrelativelayout to implement it. Also I need the textureview not exceed the screen size both on width/height. So I use 2 layers to make sure it won't exceed the…
eddiewang
  • 11
  • 2
1
vote
1 answer

Android Studio 2, Percent Layout problems

I'm using PercentRelativeLayout in my apps (you have to specifically import support for this layout). With this layout, you don't have to specify layout_width and layout_height (you use app:layout_heightpercent instead), and this worked fine on the…
1
vote
1 answer

Android: unable to set background drawable color to percentRelativeLayout

I am using view tag inside PercentRelativeLayout. I need to set background color to respective tag which I am unable to do programmatically.
Sutirth
  • 1,217
  • 4
  • 15
  • 26
1
vote
2 answers

How can I set negative percent margins in PercentRelativeLayout?

I need to set negative margin in PercentRelativeLayout but when I try it in xml as follows it doesn't work. app:layout_marginTopPercent="-10%" I tried setting negative margin programmatically when parent is measured but PercentRelativeLayout…
1
vote
0 answers

How to get heightPercent?

I'm trying to get heightPercent property value to achieve that I tried the bellow code but doesn't work : Code PercentRelativeLayout mPercentRelativeLayout = new PercentRelativeLayout(getActivity()); mPercentRelativeLayout =…
TooCool
  • 10,598
  • 15
  • 60
  • 85
0
votes
0 answers

Android Java - Make two containers side by side with percentage width

I have this scenario in an android page:
Luigino
  • 745
  • 3
  • 7
  • 26
0
votes
1 answer

How to mantain uniform alignment in layout

I'm trying to find a way to keep text views in a complex layout uniform aligned. Is there a way to position the "1B" TextView directly under the "1A" TextView and above the "1C" TextView whilst avoiding too much nesting? NB: The "1B" & "1C"…
wbk727
  • 8,017
  • 12
  • 61
  • 125
0
votes
1 answer

The Relative Layout in the Android APP is overlapping my fields

The attached is my code for the Relative Layout based Image display, The Profile name along with the username - displays the username, Email id - displays the email id, Change password and Signout. But the Field values are overlapping in the…
0
votes
0 answers

child view in percent relative layout visibility change

my aim is to change the visibility of the included layouts in each tablerow based on a single if condition. i changed the code onResume() method. but the second tablerow is not visible to me. even i printed the logs. i got View.Visible only.
0
votes
1 answer

keyboard squishes percentrelativelayout layout

I have been working on (xamarin.android) project using percentrelativelayout and have come across a problem. When the soft keyboard is displayed it squishes the entire layout. Is, there a way to resolve this? Like how to set the keyboard on top of…
vivek
  • 11
  • 4
0
votes
2 answers

Set aspect ratio in PercentageRelativeLayout programmatically

I want to set aspect ratio for my FrameLayout inside PercentRelativeLayout programmatically. I already tried in xml, it's working: