• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps PercentRelativeLayout only displaying API 23

br89

Lurker
Jul 13, 2016
2
0
Working with a `PercentRelativeLayout` (PRL from now on) to scale either `ImageViews` or `Buttons` based on screen size.

On the emulator running API 23, and on the XML preview API 23 - it looks and works beautifully. However when changing to any other API, including API 24 (or 16, etc), there is no display from `Button` or `ImageView`. Oddly enough `textView` will still show.

Done so far:

* Updated appropriate Android Studio patches (do all APIs need to be installed?)

* Added `compile 'com.android.support:percent:24.0.0'` to gradle build

* Attempt a load on physical device (phone running API 16 and one API 17) with no luck

Really getting confused by this one. Any support appreciated. Really would love the simple solution as opposed to setting view percentages programatically.

Thanks


Narrowed down to not a problem with the physical device but with the API version itself. Have yet to find a solution as to how to make PRL visible across multiple APIs at least down to 16 and up to 24.


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android: paddingBottom="@dimen/activity_vertical_margin"
android: paddingLeft="@dimen/activity_horizontal_margin"
android: paddingRight="@dimen/activity_horizontal_margin"
android: paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@String/appbar_scrolling_view_behavior"
tools:context="com.example.y"
tools:showIn="@layout/app_bar_main"
android:background="#FFF"
android:weightSum="1"
android: orientation="vertical">

<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/scrollView"
android:scrollIndicators="top">

<android.support.percent.PercentRelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="This text appears correctly"
android:textSize="28sp"
android:id="@+id/textMainTitle"
android:layout_gravity="center"
android:layout_alignParentTop="true"
android:textColor="#ffffff"
android:singleLine="true"/>

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="As does this text"
android:id="@+id/textMainSubTitle"
android:layout_gravity="center_horizontal"
android:layout_below="@id/textMainTitle"
/>


<ImageView //DOES NOT APPEAR UNLESS API23
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/btnIntro"
android:src="@drawable/button1"
app:layout_widthPercent="30%"
app:layout_heightPercent="25%"
android:layout_below="@id/textMainSubTitle"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp" />

</android.support.percent.PercentRelativeLayout>

</ScrollView>


</LinearLayout>
 
It's incredibly useless for when it works. I actually used that link/article to learn about the PRL and set it up. The build.gradle only needed the addition of compile 'com.android.support:percent:24.0.0' and has since be synced.

The UI builder will display API 23, but no others.

Unfortunately moving the order around doesn't change anything. Since it works in API 23, I don't think it's an issue with the XML layout.
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones