Professional Documents
Culture Documents
Uts Pemrograman Mobile Yogi Saputra
Uts Pemrograman Mobile Yogi Saputra
PEMROGRAMAN MOBILE 2
Disusun Oleh :
YOGI SAPUTRA
0402219001
Gambar 0.1
1. Kita Masuk terlebih dahulu pada aplikasi android studio
Gambar 0.2
Gambar 0.3
3. Buka activity app/res/menu/menu_1.xml untuk membuat tampilan menu yang akan dipanggil pada
app/res/layout/activity_main.xml.
Dan ini adalah tampilan source code pada app/res/menu/menu_1.xml
Gambar 0.4
Gambar 0.5 Gambar 0.6
<item
android:title="Photo Translator"
android:id="@+id/photo_translator"
android:icon="@drawable/ic_photo">
</item>
<item
android:title="Voice Translator"
android:id="@+id/voice_translator"
android:icon="@drawable/ic_voice">
</item>
</menu>
</item>
<item
android:title="Upgrade to Premium"
android:id="@+id/upgrade"
app:actionViewClass="android.widget.Switch"
android:icon="@drawable/ic_upgrade" />
<item
android:title="Restore Purchases"
android:id="@+id/restore"
android:icon="@drawable/ic_restore"/>
</menu>
</item>
<item
android:title="Share Text Scanner"
android:id="@+id/share"
android:icon="@drawable/ic_share" />
<item
android:title="Write a Review"
android:id="@+id/write"
android:icon="@drawable/ic_write" />
</menu>
</item>
</menu>
Tampilan design pada app/res/menu/menu_1.xml. Tampilan design menu_1.xml ini yang nanti
akan ditampilkan atau dipanggil pada activity_main.xml.
Gambar 0.7
4. Buka activity app/res/menu/menu_2.xml untuk membuat tampilan menu yang akan dipanggil pada
app/res/layout/activity_main.xml.
Dan ini adalah tampilan source code pada app/res/menu/menu_2.xml
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="0dp">
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#1755CF"
app:title="Text Scanner"
app:titleTextColor="@color/white"
android:id="@+id/toolbar"/>
</com.google.android.material.appbar.AppBarLayout>
<View
android:layout_width="match_parent"
android:layout_height="15dp"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:orientation="horizontal">
<androidx.cardview.widget.CardView
android:layout_width="120dp"
android:layout_height="100dp"
android:layout_margin="1dp"
app:cardCornerRadius="6dp"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="false">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/pondok" />
</androidx.cardview.widget.CardView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_margin="1dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="Pondok pesantren dar an nahdloh adalah....."
android:textSize="20dp"/>
<View
android:layout_width="match_parent"
android:layout_height="15dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="01 August at 09:16"
android:textSize="15dp"/>
<View
android:layout_width="match_parent"
android:layout_height="5dp" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="15dp" />
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="@color/black"/>
<View
android:layout_width="match_parent"
android:layout_height="15dp"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:orientation="horizontal">
<androidx.cardview.widget.CardView
android:layout_width="120dp"
android:layout_height="100dp"
android:layout_margin="1dp"
app:cardCornerRadius="6dp"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="false">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/pondok" />
</androidx.cardview.widget.CardView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_margin="1dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="Story pondok pesantren dar an nahdloh..."
android:textSize="20dp"
android:layout_marginStart="10dp" />
<View
android:layout_width="match_parent"
android:layout_height="15dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="1,54 MB"
android:textSize="15dp"/>
<View
android:layout_width="match_parent"
android:layout_height="5dp" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="15dp" />
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="@color/black"/>
<View
android:layout_width="match_parent"
android:layout_height="15dp"
/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/layFl"/>
</LinearLayout>
<com.google.android.material.navigation.NavigationView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/vNV"
app:menu="@menu/menu_ke_1"
app:headerLayout="@layout/nav_header"
android:layout_gravity="start"
android:fitsSystemWindows="true" />
</androidx.drawerlayout.widget.DrawerLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="0dp">
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#1755CF"
app:title="Text Scanner"
app:titleTextColor="@color/white"
android:id="@+id/toolbar"/>
</com.google.android.material.appbar.AppBarLayout>
<View
android:layout_width="match_parent"
android:layout_height="15dp"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:orientation="horizontal">
<androidx.cardview.widget.CardView
android:layout_width="120dp"
android:layout_height="100dp"
android:layout_margin="1dp"
app:cardCornerRadius="6dp"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="false">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/pondok" />
</androidx.cardview.widget.CardView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_margin="1dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="Pondok pesantren dar an nahdloh adalah....."
android:textSize="20dp"/>
<View
android:layout_width="match_parent"
android:layout_height="15dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="01 August at 09:16"
android:textSize="15dp"/>
<View
android:layout_width="match_parent"
android:layout_height="5dp" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="15dp" />
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="@color/black"/>
<View
android:layout_width="match_parent"
android:layout_height="15dp"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:orientation="horizontal">
<androidx.cardview.widget.CardView
android:layout_width="120dp"
android:layout_height="100dp"
android:layout_margin="1dp"
app:cardCornerRadius="6dp"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="false">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/pondok" />
</androidx.cardview.widget.CardView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_margin="1dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="Story pondok pesantren dar an nahdloh..."
android:textSize="20dp"
android:layout_marginStart="10dp" />
<View
android:layout_width="match_parent"
android:layout_height="15dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="1,54 MB"
android:textSize="15dp"/>
<View
android:layout_width="match_parent"
android:layout_height="5dp" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="15dp" />
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="@color/black"/>
<View
android:layout_width="match_parent"
android:layout_height="15dp"
/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/layFl"/>
</LinearLayout>
<com.google.android.material.navigation.NavigationView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/vNV"
app:menu="@menu/menu_ke_1"
app:headerLayout="@layout/nav_header"
android:layout_gravity="start"
android:fitsSystemWindows="true" />
</androidx.drawerlayout.widget.DrawerLayout>
Tampilan design pada app/res/layout/menu_2.xml. Tampilan design menu_2.xml ini yang nanti
akan ditampilkan atau dipanggil pada activity_main.xml.
5. Buka activity app/res/layout/nav_header.xml untuk membuat tampilan menu yang akan dipanggil
pada app/res/layout/activity_main.xml.
Dan ini adalah tampilan source code pada app/res/layout/nav_header.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:background="#1755CF"
android:gravity="bottom"
android:padding="15dp"
android:layout_height="120dp">
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="55dp"
android:layout_height="55dp"
android:src="@drawable/poto"
android:layout_marginLeft="5dp"
android:layout_marginTop="15dp"/>
<LinearLayout
android:layout_width="165dp"
android:layout_height="44dp"
android:layout_gravity="bottom"
android:layout_marginBottom="7dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:text="Jamaludin"
android:textColor="#FFFFFF"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:text="0402219005"
android:textColor="#FFFFFF"
android:textSize="15sp"
android:textStyle="bold" />
</LinearLayout>
<ImageButton
android:layout_width="55dp"
android:layout_height="55dp"
android:background="?attr/selectableItemBackgroundBorderless"
app:srcCompat="@drawable/ic_power"
app:tint="@color/white"
android:clickable="true"
android:contentDescription="TODO" />
</LinearLayout>