I am using support percent library in my project.
compile 'com.android.support:percent:23.1.0'
I have three ImageViews in a LinearLayout which are supposed to take the space equally (in horizontal direction). But since percent support library has PercentRelativeLayout and PercentFrameLayout only so I googled for PercentLinearLayout and found one sample for it.
Here's the layout code:
<com.example.layouts.PercentLinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="horizontal">
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="@drawable/img_01"
app:layout_widthPercent="33.3%" /> // <- what should I write here?
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="@drawable/img_02"
app:layout_widthPercent="33.3%" /> // <- and here..
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="@drawable/img_03"
app:layout_widthPercent="33.3%" /> // <- and here..
</com.example.layouts.PercentLinearLayout>
You can see I have assigned 33.3% space to each ImageView but there's still 0.1% space left. Although 0.1% screen space is not that significant to notice but the current approach just doesn't seem right to me.
PS: Earlier I was using weights (each ImageView had weight 1) but since it's not good for performance so I decided to go with percentages instead.
You could've used
LinearLayout
withweightSum
set to 3 andandroid:layout_weight="1"
to eachImageView