谷歌已经展示了一些很好的方式,按钮在这里显示在棒棒糖上.
我在谈论凸起和平面按钮.
除了特殊效果(波纹等......)之外,我怎样才能在Lollipop前版本上模仿它们?
当然,在棒棒糖及以上,我想使用特效.
我知道有很多(甚至很多)关于这个的帖子,但我没有看到任何试图完全模仿它.
在代码中,是否有任何方法可以使按钮持续闪烁,然后在按下时停止闪烁?
我期待自定义Switch按钮变为如下:

怎么做到这一点?
我试图在图像按钮上设置前景图像.经过一些研究,我发现了这个代码示例:
<ImageButton android:text="Button" android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon"/>
Run Code Online (Sandbox Code Playgroud)
我的查询是如何在代码中实际实现android:src.
这是我的listview点击事件:
lv1.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> a, View v, int position, long id) {
Object o = lv1.getItemAtPosition(position);
ItemDetails obj_itemDetails = (ItemDetails)o;
Toast.makeText(ListViewImagesActivity.this, "You have chosen : " + " " + obj_itemDetails.getName(), Toast.LENGTH_LONG).show();
}
});
Run Code Online (Sandbox Code Playgroud)
这是我的按钮点击事件:
btnNxt = (Button) findViewById(R.id.btnNext);
btnNxt.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
//Here I need to get that position
});
Run Code Online (Sandbox Code Playgroud)
现在我需要获得点击的listview项目的位置..我已经全局声明了postion但总是给我位置1.
谁能说我怎么得到这个位置?
android listitem buttonclick android-listview android-button
我需要一个Edittext旁边的Search button.本EditText应填写尽可能多的宽度尽可能的按钮应该是正确的,并正好足够大,有它的文本.
它现在看起来像这样:
[EDIT TEXT][Search]
Run Code Online (Sandbox Code Playgroud)
但应该是这样的:
[.......EDIT TEXT.......][Search]
Run Code Online (Sandbox Code Playgroud)
这是XML:
<RelativeLayout android:id="@+id/RelativeLayout01" android:layout_width="fill_parent" android:layout_height="wrap_content">
<EditText android:id="@+id/search_box"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="type to filter"
android:inputType="text"
android:maxLines="1" />
<Button android:id="@+id/search_text"
android:layout_toRightOf="@id/search_box"
android:text="Search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud) 有没有办法为将要应用的XML文件中的Button指定替代背景图像/颜色onClick,或者我是否必须Button.setBackground()在onClickListener?
我使用这种风格来改变我的背景颜色Button:
<style name="AccentButton" parent="Widget.AppCompat.Button.Colored">
<item name="colorButtonNormal">@color/colorAccent</item>
<item name="android:textColor">@color/white</item>
</style>
Run Code Online (Sandbox Code Playgroud)
在布局中:
<Button
android:id="@+id/login_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/fragment_login_login_button"
app:theme="@style/AccentButton"/>
Run Code Online (Sandbox Code Playgroud)
有用.但是当我打电话setEnabled(false)给它时Button,它保持相同的颜色.我该如何处理这个案子?
我想在Buttons上使用涟漪效果.AppCompat v22.1为AppCompat着色添加了AppCompatButton和新功能.
我的布局:
<android.support.v7.widget.AppCompatButton
android:id="@+id/add_remove_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:backgroundTint="@color/primary"
android:textColor="@android:color/white"
android:text="Remove" />
Run Code Online (Sandbox Code Playgroud)
在我的API 22测试设备上,涟漪效应完美无缺,但我正在编写API 11,不幸的是backgroundTint需要API> = 21.如何在旧API版本上将涟漪效果设置为按钮?
我下面从这样的问题提示此创建一个按钮样式像材料设计建议.
但是,我需要通过继承Widget.AppCompat.Button.Colored样式和设置radius参数来更改角半径并且无法这样做.
我怎么能有相同的风格,但有圆角?
android android-button android-support-library material-design android-support-design