Search code examples
androidandroid-studio-2.0android-percentrelativelayout

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 previous Android Studio version. But now that I've updated to the new Android Studio 2, I get errors, it says I must define the default height and width values. What do I do?


Solution

  • This is not exactly a solution, but it does prevent the error.

    I have just been defining the layout_width and layout_height as either 0dp or wrap_content and then set my layout_widthPercent and layout_heightPercent to whatever percent I want.

    It is important to note that if you set the non-percent width and height to wrap_content alongside setting percents, then views larger than the allowed percentage values will instead be resized using wrap_content rules. I have no clue if something similar happens when using 0dp vs wrap_content.