Tabii, mevcut XML düzeninizi Google Keep uygulamasındaki metin boyutlarına göre ayarlayabilir ve Google Keep'e benzer bir liste öğesi tasarımı oluşturabiliriz. Ayrıca, seçildiğinde etrafının outline ile çizilmesini sağlayacak bir drawable da ekleyebiliriz. İşte adım adım nasıl yapabileceğiniz:
1. Mevcut Düzenin Metin Boyutlarını Ayarlama
Google Keep'teki metin boyutlarını taklit etmek için genellikle şu boyutlar kullanılır:
- Kategori: 14sp
- Başlık: 24sp
- İçerik: 16sp
Aşağıda, mevcut XML düzeninizi bu metin boyutlarına uygun şekilde güncellenmiş hali bulunmaktadır:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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:id="@+id/relativeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".FragmentEdit"
android:background="@color/backgroundColor"
android:clickable="true"
android:focusable="true">
<!-- Fragment Toolbar -->
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/fragmentToolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="?attr/actionBarTheme"
app:title="Add or Edit Note"/>
<!-- Bottom App Bar -->
<com.google.android.material.bottomappbar.BottomAppBar
android:id="@+id/bottomAppBar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_alignParentBottom="true"
app:fabCradleMargin="10dp"
app:fabCradleRoundedCornerRadius="10dp"
app:backgroundTint="@color/primaryColor">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textViewCreatedAtLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CreatedAt: "
android:textColor="@android:color/white"
android:textSize="14sp" />
<TextView
android:id="@+id/textViewTimestamp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="29.05.1986 4:23"
android:textColor="@android:color/white"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textViewUpdatedAtLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="UpdatedAt: "
android:textColor="@android:color/white"
android:textSize="14sp" />
<TextView
android:id="@+id/textViewUpdatedAt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="29.05.1986 4:23"
android:textColor="@android:color/white"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
</com.google.android.material.bottomappbar.BottomAppBar>
<!-- Scrollable Content -->
<ScrollView
android:id="@+id/scrollViewContent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/fragmentToolbar"
android:layout_above="@id/bottomAppBar"
android:padding="16dp"
android:background="@color/backgroundColor">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
android:id="@+id/editTextCategory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Kategori"
android:inputType="text"
android:minHeight="48dp"
android:textSize="14sp" />
<EditText
android:id="@+id/editTextTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Başlık"
android:inputType="text"
android:minHeight="48dp"
android:textSize="24sp" />
<EditText
android:id="@+id/editTextContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="İçerik"
android:inputType="textMultiLine"
android:minHeight="48dp"
android:minLines="3"
android:textSize="16sp"
android:background="@android:color/transparent"/>
</LinearLayout>
</ScrollView>
</RelativeLayout>
2. Google Keep Benzeri Liste Öğesi Tasarımı
Google Keep'teki liste öğeleri genellikle bir onay kutusu (checkbox) ve metin içerir. Aşağıda buna benzer bir liste öğesi tasarımı için list_item.xml adlı yeni bir dosya oluşturabilirsiniz:
res/layout/list_item.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:background="@drawable/list_item_background"
android:clickable="true"
android:focusable="true">
<!-- Onay Kutusu -->
<CheckBox
android:id="@+id/checkBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:buttonTint="@color/primaryColor"/>
<!-- Liste Öğesi Metni -->
<TextView
android:id="@+id/textViewListItem"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toEndOf="@id/checkBox"
android:layout_marginStart="16dp"
android:text="Liste öğesi metni"
android:textSize="16sp"
android:textColor="@android:color/black"
android:layout_centerVertical="true" />
</RelativeLayout>
3. Seçili Durum İçin Outline Gösteren Drawable Oluşturma
Bir öğe seçildiğinde etrafında outline göstermek için özel bir drawable kullanabilirsiniz. Aşağıda list_item_background.xml adında bir drawable dosyası oluşturulmuştur:
res/drawable/list_item_background.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Seçili Durum -->
<item android:state_selected="true">
<shape android:shape="rectangle">
<solid android:color="@android:color/transparent" />
<stroke
android:width="2dp"
android:color="@color/primaryColor" />
<corners android:radius="4dp" />
</shape>
</item>
<!-- Varsayılan Durum -->
<item>
<shape android:shape="rectangle">
<solid android:color="@android:color/transparent" />
<stroke
android:width="1dp"
android:color="@android:color/darker_gray" />
<corners android:radius="4dp" />
</shape>
</item>
</selector>
Bu drawable, bir öğe seçildiğinde etrafında belirgin bir çizgi görünmesini sağlar.
4. RecyclerView Adapter'ında Seçim Durumunu Yönetme
Drawable'ın doğru şekilde çalışabilmesi için RecyclerView Adapter'ınızda seçim durumunu yönetmeniz gerekir. Aşağıda Kotlin ile yazılmış basit bir adapter örneği bulunmaktadır:
ListAdapter.kt
class ListAdapter(private val items: List<String>) : RecyclerView.Adapter<ListAdapter.ViewHolder>() {
private var selectedPosition = RecyclerView.NO_POSITION
inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val checkBox: CheckBox = itemView.findViewById(R.id.checkBox)
val textView: TextView = itemView.findViewById(R.id.textViewListItem)
init {
itemView.setOnClickListener {
val previousSelected = selectedPosition
selectedPosition = adapterPosition
notifyItemChanged(previousSelected)
notifyItemChanged(selectedPosition)
}
}
fun bind(text: String, isSelected: Boolean) {
textView.text = text
itemView.isSelected = isSelected
}
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.list_item, parent, false)
return ViewHolder(view)
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
holder.bind(items[position], position == selectedPosition)
}
override fun getItemCount(): Int = items.size
}
Bu adapter, bir öğeye tıklandığında seçili pozisyonu günceller ve drawable'ın seçili durumu yansımasını sağlar.
5. RecyclerView'unuzu Ayarlama
Son olarak, RecyclerView'unuzu adapter ile ayarlayarak liste öğelerinizi görüntüleyebilirsiniz:
// Örneğin, Fragment veya Activity içinde
val recyclerView: RecyclerView = findViewById(R.id.recyclerView)
recyclerView.layoutManager = LinearLayoutManager(this)
recyclerView.adapter = ListAdapter(yourListOfItems)
6. Tamamlanmış Örnek Düzen
Google Keep'e benzer bir not düzenleme ve listeleme işlemi için tamamlanmış bir XML yapısı aşağıda verilmiştir.
res/layout/activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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:id="@+id/relativeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:background="@color/backgroundColor"
android:clickable="true"
android:focusable="true">
<!-- Fragment Toolbar -->
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/fragmentToolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="?attr/actionBarTheme"
app:title="Add or Edit Note"/>
<!-- Bottom App Bar -->
<com.google.android.material.bottomappbar.BottomAppBar
android:id="@+id/bottomAppBar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_alignParentBottom="true"
app:fabCradleMargin="10dp"
app:fabCradleRoundedCornerRadius="10dp"
app:backgroundTint="@color/primaryColor">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textViewCreatedAtLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CreatedAt: "
android:textColor="@android:color/white"
android:textSize="14sp" />
<TextView
android:id="@+id/textViewTimestamp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="29.05.1986 4:23"
android:textColor="@android:color/white"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textViewUpdatedAtLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="UpdatedAt: "
android:textColor="@android:color/white"
android:textSize="14sp" />
<TextView
android:id="@+id/textViewUpdatedAt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="29.05.1986 4:23"
android:textColor="@android:color/white"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
</com.google.android.material.bottomappbar.BottomAppBar>
<!-- Scrollable Content -->
<ScrollView
android:id="@+id/scrollViewContent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/fragmentToolbar"
android:layout_above="@id/bottomAppBar"
android:padding="16dp"
android:background="@color/backgroundColor">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
android:id="@+id/editTextCategory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Kategori"
android:inputType="text"
android:minHeight="48dp"
android:textSize="14sp" />
<EditText
android:id="@+id/editTextTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Başlık"
android:inputType="text"
android:minHeight="48dp"
android:textSize="24sp" />
<EditText
android:id="@+id/editTextContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="İçerik"
android:inputType="textMultiLine"
android:minHeight="48dp"
android:minLines="3"
android:textSize="16sp"
android:background="@android:color/transparent"/>
<!-- RecyclerView için Alan -->
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:scrollbars="vertical"/>
</LinearLayout>
</ScrollView>
</RelativeLayout>
7. Ekstra Ayarlar ve Renkler
@color/primaryColor ve diğer renk referanslarınızın tanımlı olduğundan emin olun. res/values/colors.xml dosyanızı aşağıdaki gibi güncelleyebilirsiniz:
res/values/colors.xml
<resources>
<color name="primaryColor">#6200EE</color>
<color name="backgroundColor">#FFFFFF</color>
<!-- Diğer renk tanımlamaları -->
</resources>
8. Sonuç
Bu adımlar sonucunda, Google Keep uygulamasına benzer bir not düzenleme ve listeleme arayüzüne sahip olacaksınız. Metin boyutları ayarlanmış, liste öğeleri için uygun bir tasarım oluşturulmuş ve seçili durumlarda outline görünümü eklenmiştir. RecyclerView ve Adapter kullanarak dinamik liste öğeleri ekleyebilir ve yönetebilirsiniz.
Eğer daha fazla özelleştirme yapmak veya belirli bir konuda yardıma ihtiyaç duyarsanız, lütfen bana bildirin!