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
2
votes
1 answer

Android - ScrollView and PercentRelativeLayout

I have a problem with combining the android.support.percent.PercentRelativeLayout with ScrollView. The following xml file
2
votes
0 answers

Android: percentage of PercentRelativeLayout

I tried PercentRelativeLayout and I have a question about it. Positioning to Button, TextView etc. I am using like that app:layout_heightPercent="9.595274%" app:layout_marginTopPercent="10.194942%" …
2
votes
3 answers

Android - Put a button over an ImageView to the exact spot

I have an ImageView (human body) and buttons over this image. Is it possible somehow easily create this in RelativeLayout for the most different screen sizes? Or should I create different layouts for different screen sizes? How would you proceed?…
2
votes
1 answer

how to set ImageView width using Percent support lib and maintain aspect ratio?

Using the Android Percent Support Library, how can I set the width of an ImageView to a percentage of its containing PercentRelativeLayout, while scaling the height in such a way as to maintain the original aspect ratio?
1
vote
0 answers

TopMarginPercent in PercentRelativeLayout behaves strangely in nested Views

I am using PercentRelativeLayout for positioning a view on an image. However, it seems like that marginTopPercent always depends on the height of the entire view even if the height of my PercentRelativeView is smaller. How can I make it dependent on…
1
vote
0 answers

how to use PercentRelativeLayout in older API Levels?

I am writing here because I have a huge problem: I developed a quite big app for Android using PercentRelativeLayout everywhere (I know that now it is deprecated but it was not when I've done the project and I cannot rewrite it all). I've tried the…
1
vote
0 answers

When I`m use the scroll, the views not displayed

When I use a scroll, the views that appear in the tag Percentage library are not displayed. This problem occurs when I run the program on the device emulator and when the program is executed, the Activity is blank from each view.
Mohammad
  • 11
  • 1
1
vote
1 answer

Android Studio - How to inflate an xml layout containing a view that use percentage params

I am here because I would like to use multiple times the same cardView layout, changing simply some information contained in it and then adding it to a view contained in the main xml layout. The problem is that the view to which append the created…
1
vote
0 answers

DialogFragment with PercentRelativeLayout

I faced a problem with DialogFragment. The layout is changing depending on the API. I use a PercentRelativeLayout. For API >= 21, the sizes are percentages of the screen and there is no title. Pof API < 21, the sizes change (I guess they are…
1
vote
3 answers

ImageView expanding container despite adjustViewBounds

I want to wrap an ImageView inside a LinearLayout so that I can center a group of views. However, the original image needs to be scaled down to fit in the ImageView, and the original size expands the LinearLayout, despite my use of…
1
vote
1 answer

Android setting widthPercent of PercentRelativeLayout programatically (with fixed aspectRatio) does not update the height correctly

As you may know it too, you can change the widthPercent of PercentRelativeLayout in code just like this: PercentRelativeLayout.LayoutParams params = ((PercentRelativeLayout.LayoutParams) view.getLayoutParams()); PercentLayoutHelper.PercentLayoutInfo…
Mostafa Aghajani
  • 1,844
  • 2
  • 14
  • 19
1
vote
1 answer

How to set percentHeight in PercentRelativeLayout programmatically

I want to set the height of PercentRelativeLayout in percentage. PercentRelativeLayout layout = new PercentRelativeLayout(this); PercentRelativeLayout.LayoutParams llp = new…
elbert rivas
  • 1,464
  • 1
  • 17
  • 15
1
vote
0 answers

PercentRelativeLayout doens't show if no minHeight

I currently developing an app with different card, which are include in a NestedScollView. But if i don't put an attribute minHeight on the CardView nothing appair. XML
1
vote
2 answers

How to use PercentRelativeLayout in API 25

I want to use PercentRelativeLayout but I have the compileSdkVersion 25. Which dependency should I add to build.grade(Module: app)?
Falcoa
  • 2,612
  • 1
  • 20
  • 30
1
vote
1 answer

PercentRelativeLayout not taking height and margin top/bottom related attributes in percentage

I am using percent relative layout to defined the layout of a card view. It works fine when defining width and horizontal margin attributes. However, defining height and margin top/bottom in percentages has no effect on the layout. Here is the xml…