Comments (3)
Hi @EnriekNP, thanks for filing! Could you please share the code you're currently using to try to override the selected dropdown view? It would also be great if you could share a mock of what you're trying to achieve.
from material-components-android.
ok , let me make it first
from material-components-android.
this is the code and the look that i want @afohrman ...
the dropdown layout
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/layoutDropDown"
style="@style/Widget.Material3.TextInputLayout.FilledBox.ExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Test Exposed Drop Down"
app:boxBackgroundColor="@null"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.textfield.MaterialAutoCompleteTextView
android:id="@+id/autoComplelteTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawablePadding="10dp"
android:dropDownHeight="175dp"
android:inputType="none"
android:textColor="@color/black" />
</com.google.android.material.textfield.TextInputLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
the dropdown item layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/dropdown"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:id="@+id/dropdown_item_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginVertical="10dp"
android:paddingStart="24dp"
android:paddingEnd="12dp"
tools:src="@drawable/ic_test" />
<TextView
android:id="@+id/dropdown_item_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="test" />
</LinearLayout>
the adapter
class TestAdapter(
ctx: Context,
resource: Int,
private val items: List<Test>
) : ArrayAdapter<Test>(ctx, resource, items) {
val inflater: LayoutInflater = LayoutInflater.from(ctx)
override fun getItem(position: Int): Test {
return items[position]
}
override fun getCount(): Int {
return items.size
}
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
val view = convertView ?: inflater.inflate(
R.layout.dropdown_item,
parent,
false
)
view.setPadding(0, view.paddingTop, view.paddingRight, view.paddingBottom)
val item = items[position]
val iconImageView = view.findViewById<ImageView>(R.id.dropdown_item_icon)
iconImageView.setPadding(
0,
iconImageView.paddingTop,
iconImageView.paddingRight,
iconImageView.paddingBottom
)
val text1 = view.findViewById<TextView>(R.id.dropdown_item_name)
iconImageView.setImageResource(item.icon)
text1.text = item.name
return view
}
override fun getDropDownView(position: Int, convertView: View?, parent: ViewGroup): View {
return getView(position, convertView, parent)
}
}
the class
data class Test(val icon: Int, val name: String)
and how i call the adapter in the fragment
val listTest = getListItem()
val testAdapter = TestAdapter(requireContext(), R.layout.dropdown_item,listTest)
binding.autoComplelteTextView.setAdapter(testAdapter)
what i want is like this (sorry if it's not good, i just edit the image in figma)
from material-components-android.
Related Issues (20)
- [Tabs] tabSelectedTextAppearance and tabTextAppearance , tab selected , the textSize in tabSelectedTextAppearance not work
- [Button] Buttons with insets are broken in RTL mode
- [BottomNavigation] BottomNavigationView can dynamic changes change postison? HOT 2
- [Slider] Haptic feedback
- [NavigationView] Menuitem enable/disable does not change the color HOT 8
- Material 3 Date Picker with Disabled Dates: Disabled Dates are Focusable with External Keyboard
- [Search bar] Should stop listening for back callbacks when detached from window HOT 1
- [Slider] String translations are missing
- [NavigationView] Incorrect section label position in RTL
- [Progress indicator] Doesn't spin on API level 21 HOT 3
- [Motion] Activity to Fragment Transition HOT 1
- Cannot compile aar with new version from com.google.android.material:material: Android resources missing HOT 2
- [TopAppBar] AppBarLayout responds to all scrolling views
- [SearchView] When using android:enableOnBackInvokedCallback="true" , the SearchView is collapsed together with the keyboard, instead of just the keyboard HOT 10
- DrawerLayout not retaining selected state during configuration change with Jetpack Navigation HOT 6
- Navigation Rail like a NavigationView with Jetpack Navigation HOT 3
- [SearchView] Undocumented how to actually use it HOT 9
- [Search] Add a link to the secret demo in the docs
- Crash on BottomSheetBehavior.onMeasureChild on Android (7,8 and 9) HOT 4
- [MaterialRadioButton] Add support for setting the padding between the left edge of the layout and the radio button
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from material-components-android.