Skip to content

Instantly share code, notes, and snippets.

@VijayMakwana
Last active June 8, 2016 05:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VijayMakwana/e7fe04aaaa1cbaff8c6c98af1031e26a to your computer and use it in GitHub Desktop.
Save VijayMakwana/e7fe04aaaa1cbaff8c6c98af1031e26a to your computer and use it in GitHub Desktop.
Example of PercentRelativeLayout
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'de.hdodenhof:circleimageview:1.3.0'
compile 'com.android.support:design:23.0.0'
compile 'com.android.support:percent:23.0.0'
}
<?xml version="1.0" encoding="utf-8"?>
<android.support.percent.PercentRelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/rel_adpter"
android:layout_width="match_parent"
android:layout_height="70dp"
android:padding="2dp">
<ImageView
android:id="@+id/iv_location"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:src="@drawable/map_blue"
android:padding="12dp"
android:layout_alignWithParentIfMissing="true"
app:layout_marginLeftPercent="1%"
app:layout_widthPercent="4%" />
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/iv_profile_patient"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:layout_margin="10dp"
android:layout_alignWithParentIfMissing="true"
android:layout_toRightOf="@+id/iv_location"
android:src="@drawable/register_patient"
app:layout_marginLeftPercent="1%"
app:layout_widthPercent="5%" />
<TextView
android:id="@+id/tv_patient_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_alignWithParentIfMissing="true"
android:layout_toRightOf="@+id/iv_profile_patient"
android:text="@string/doctor"
android:textSize="@dimen/txt"
android:textStyle="bold"
app:layout_widthPercent="25%" />
<LinearLayout
android:id="@+id/line1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignWithParentIfMissing="true"
android:layout_below="@+id/tv_patient_name"
android:layout_toRightOf="@+id/iv_profile_patient"
android:orientation="horizontal"
app:layout_widthPercent="25%">
<TextView
android:id="@+id/tv_dob"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/doctor"
android:layout_alignWithParentIfMissing="true"
android:textSize="@dimen/txt" />
<TextView
android:id="@+id/tv_gender"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/doctor"
android:layout_alignWithParentIfMissing="true"
android:textSize="@dimen/txt" />
</LinearLayout>
<TextView
android:id="@+id/tv_problem"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginTop="12dp"
android:layout_alignWithParentIfMissing="true"
android:layout_toRightOf="@+id/line1"
android:text="@string/doctor"
android:textSize="@dimen/txt"
app:layout_marginLeftPercent="1%"
app:layout_widthPercent="18%" />
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/iv_profile_doctor"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:layout_margin="10dp"
android:layout_alignWithParentIfMissing="true"
android:layout_toRightOf="@+id/tv_problem"
android:src="@drawable/register_patient"
app:layout_marginLeftPercent="1%"
app:layout_widthPercent="5%" />
<TextView
android:id="@+id/tv_doctor_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_toRightOf="@+id/iv_profile_doctor"
android:text="@string/doctor"
android:textSize="@dimen/txt"
android:layout_alignWithParentIfMissing="true"
android:textStyle="bold"
app:layout_widthPercent="25%" />
<TextView
android:id="@+id/tv_qualification"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_below="@+id/tv_patient_name"
android:layout_toRightOf="@+id/iv_profile_doctor"
android:text="@string/doctor"
android:layout_alignWithParentIfMissing="true"
android:textSize="@dimen/txt"
app:layout_widthPercent="25%" />
<TextView
android:id="@+id/tv_time"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_toRightOf="@+id/tv_doctor_name"
android:text="@string/doctor"
android:layout_alignWithParentIfMissing="true"
android:textSize="@dimen/txt"
app:layout_marginLeftPercent="1%"
app:layout_widthPercent="12%" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_alignWithParentIfMissing="true"
android:layout_alignParentBottom="true"
android:background="#d2d0d0"></View>
</android.support.percent.PercentRelativeLayout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment