<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#279BF8"/>
<corners android:topLeftRadius="28dp" android:topRightRadius="28dp"/>
</shape>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/home_nav"
android:icon="@drawable/ic_baseline_home_24"
android:title="Home"/>
<item
android:id="@+id/user_nav"
android:icon="@drawable/ic_baseline_account_circle_24"
android:title="User"/>
</menu>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@drawable/nav_bg"
app:menu="@menu/menu_item_bottom_nav" />
</RelativeLayout>
<shape
android:shape="rectangle"
xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:bottomLeftRadius="50dp"
android:bottomRightRadius="50dp"/>
<solid android:color="@color/design_default_color_primary"/>
</shape>
bottomNavigationView.setOnItemSelectedListener {
when(it.itemId){
R.id.home_nav -> replaceFragment(homeFragment)
R.id.user_nav -> replaceFragment(anggotaFragment)
}
true
}
}
private fun replaceFragment(fragment: Fragment){
if (fragment != null){
val transaction = supportFragmentManager.beginTransaction()
transaction.replace(R.id.fragment_container, fragment)
transaction.commit()
}
}
}
</resources>
16. Menonaktifkan Action Bar pada theme default.
Klik manifest -> ubah android:theme menjadi NoActionBar
android:theme="@style/AppTheme.NoActionBar">
17. Tambahkan gambar youtube di drawable untuk menampilkan gambarnya di menu utama
<ImageView
android:src="@drawable/bg_half_circle"
android:layout_width="match_parent"
android:layout_height="150dp"/>
<TextView
android:id="@+id/tv_welcome"
android:text="Selamat Datang"
android:layout_margin="16dp"
android:textSize="20sp"
android:textColor="#FFFFFF"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<ImageView
android:layout_alignParentRight="true"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:src="@drawable/ic_baseline_settings_24"
android:layout_width="20dp"
android:layout_height="20dp"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_home"
android:layout_below="@+id/tv_welcome"
android:layout_margin="16dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/rv_home"
android:layout_margin="16dp">
<TextView
android:textStyle="bold"
android:layout_width="match_parent"
android:textSize="18sp"
android:layout_height="wrap_content"
android:text="Info Company" />
<androidx.cardview.widget.CardView
android:layout_marginTop="8dp"
android:background="#FFFFFF"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="10dp"
app:cardElevation="10dp"
>
<ImageView
android:src="@drawable/download"
android:id="@+id/ytb"
android:layout_width="match_parent"
android:layout_height="200dp"/>
</androidx.cardview.widget.CardView>
<TextView
android:layout_marginTop="10dp"
android:textStyle="bold"
android:layout_width="match_parent"
android:textSize="18sp"
android:layout_height="wrap_content"
android:text="Sosial Media Company" />
</LinearLayout>
</RelativeLayout>
class ModelInfo {
var nameInfo = ""
var imageInfo = ""
var detailInfo = ""
}
object DataInfo {
"https://assets.jalantikus.com/assets/cache/500/284/userfiles/2019/02/04/
aplikasi-ojek-online-3-a8d5d.jpg",
"https://ecs7.tokopedia.net/img/cache/700/product-
1/2016/7/26/9410026/9410026_bbde85d5-694c-4a27-a3b3-db2159a48ae7.jpg",
"https://ecs7.tokopedia.net/img/cache/700/product-
1/2016/7/26/9410026/9410026_bbde85d5-694c-4a27-a3b3-db2159a48ae7.jpg"
list.add(modelInfo)
return list
}
}
23. Membuat item_info_company
Klik kanan layout -> klik new -> klik Layout Resource File, tulis nama file
“item_info_company”
<androidx.cardview.widget.CardView
app:cardCornerRadius="10dp"
app:cardElevation="6dp"
android:layout_margin="16dp"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="200dp">
<ImageView
android:id="@+id/img_info"
android:scaleType="centerCrop"
android:src="@mipmap/ic_launcher"
android:layout_width="match_parent"
android:layout_height="200dp"/>
<TextView
android:id="@+id/tv_judul_info"
android:layout_alignParentBottom="true"
android:gravity="center"
android:background="#48131010"
android:textColor="#fff"
android:text="Judul . . ."
android:textSize="18sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</RelativeLayout>
</androidx.cardview.widget.CardView>