我目前正在使用材质设计文本InputLayout OutlineBox,如下所示:
<android.support.design.widget.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:id="@+id/myEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Title"
android:inputType="text"/>
</android.support.design.widget.TextInputLayout>
我试图添加一个下拉框微调
在我的TextInputEditText下,并希望保持相同的样式:OutlinedBox。
我看到材料设计、材料设计文本字段似乎支持下拉列表。如此处显示的区域:
我目前正在使用微调器生成下拉列表。
<Spinner
style="@style/Widget.AppCompat.Spinner.DropDown"
android:id="@+id/option"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:dropDownWidth="match_parent" />
在OutlinedBox设计之后添加下拉列表似乎是不可能的。有没有一个库可以让我实现这一点,或者有没有更好的方法在Materials Design中实现这一点?
我认为本文档根本没有显示微调器。我认为它显示了一个带有下拉图标的
文本输入布局
。
在解剖学部分的图标部分,它说
5.下拉图标
下拉箭头指示文本字段具有嵌套的选择组件。
现在,你如何提供“嵌套选择组件”我不确定。。。
只需将材质组件库中包含的TextInputLayout
与style小部件一起使用即可。材料组件。文本输入布局。大纲框。ExposedDropdownMenu
。
比如:
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
android:hint="Hint text"
...>
<AutoCompleteTextView
android:id="@+id/outlined_exposed_dropdown_editable"
.../>
</com.google.android.material.textfield.TextInputLayout>
我假设你想在TextInputLayout
中有一个公开的下拉菜单,我也有同样的问题,你可以在TextInputLayout
中使用AutoCompleteTextView
,如下所示在XML
中。下面是我如何处理这个问题的一个例子。
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingRight="30dp"
android:paddingEnd="30dp"
tools:ignore="RtlSymmetry"
android:layout_margin="5dp">
<ImageView
android:layout_width="30dp"
android:layout_margin="10dp"
android:layout_height="match_parent"
app:srcCompat="@drawable/ic_location_city_black_24dp"
android:layout_gravity="center"
/>
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox.ExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Type"
android:orientation="horizontal"
>
<AutoCompleteTextView
android:id="@+id/filled_exposed_dropdown"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="none"/>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
</LinearLayout>
您还需要一个项目布局资源来填充下拉式弹出窗口。下面的示例提供了遵循材质设计指南的布局。
res/布局/dropdown_menu_popup_item.xml
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:ellipsize="end"
android:maxLines="1"
android:textAppearance="?attr/textAppearanceSubtitle1"/>
在您的类中,根据您想要的内容添加以下代码。
String[] type = new String[] {"Bed-sitter", "Single", "1- Bedroom", "2- Bedroom","3- Bedroom"};
ArrayAdapter<String> adapter =
new ArrayAdapter<>(
this,
R.layout.dropdown_menu_popup_item,
type);
AutoCompleteTextView editTextFilledExposedDropdown =
findViewById(R.id.filled_exposed_dropdown);
editTextFilledExposedDropdown.setAdapter(adapter);
Incase这无助于在材料设计页面中检查Expose Dropdown Menus。[https://material.io/develop/android/components/menu/][1]
这是我关于堆栈溢出的第一个答案,希望能有所帮助。
简单地说,我不想使用第三方库,我只想知道是否可以使用android支持库以及如何做到这一点。
我在Eclipse控制台上没有重述任何错误,但当我在智能手机上打开应用程序(三星Galaxy Ace 4 with Android 4.4.4)时,会出现一个弹出图标,显示,我收到错误。 唯一可行的解决方案就是这样,但它不支持Lollipop之前的设备(仅支持API 21及更高版本)。 我最终尝试使用在这里找到的一个不同的支持库,但我不知道如何使用“Ray's Lib”库。
我正在制作一个有棱角的材料网站。它包含一个日期选择器。日期选择器启用了弹出窗口,但禁用了输入。在该样式下输入一条虚线。如何更改样式以使虚线为实线? 文档中有一个禁用输入的日期选择器示例:https://material.angular.io/components/datepicker/examples请参阅“禁用日期选择器”部分。
如何使用材质设计将按钮放置在图中所示的位置? 这是index.html模板上的代码。 这是材质设计的css样式。 Lorem ipsum dolor sit amet,consectetur adipisicing elit,sed do eusmod tempor incidunt ut labore et dolore magna aliqua.Ut enim ad minim veniam,
有人能告诉我如何开始实施Android Material Design guide中描述的垂直非线性步进控制吗 http://www.google.com/design/spec/components/steppers.html
嗨,我是一个新的材料设计,我试图使卡片部分响应媒体查询和Flex。由于某种原因,当卡片切换到列时,只显示图像的一部分,而卡片的其余部分(如文本)不再显示。我发现让组件响应非常混乱。我是不是漏掉了什么?