标签: imagebutton

imagebutton给我错误:[辅助功能]图像上缺少contentDescription属性

[辅助功能]图像上缺少contentDescription属性

这个错误意味着什么,我该如何解决?

<ImageButton
    android:id="@+id/callbannerbuttonpg1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="157dp"
    android:background="@null"
    android:src="@drawable/callbanner"
    android:visibility="invisible" />
Run Code Online (Sandbox Code Playgroud)

android accessibility imagebutton

14
推荐指数
2
解决办法
3万
查看次数

当满足条件时,如何以编程方式更改ImageButton src目标?

我有一个学校项目,我试图让手电筒应用程序.对于开/关ImageButton,我想要有4个自定义图像.

如果手电筒关闭:-turn_on.png(默认)-turn_on_pressing.png(state pressed = true)

如果手电筒开启:-turn_off.png(默认)-turn_off_pressing.png(状态按=真)

我希望更改ImageButton src目标以在"on_selector.xml"和"off_selector.xml"之间进行更改.最初我能够setImageResource()更改默认按钮图像.现在,我正在尝试添加自己的新闻图像,我正处于一个非常困难的时期.

Application.java:

import android.app.Activity;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.os.Bundle;
import android.hardware.Camera;
import android.hardware.Camera.Parameters;
import android.view.View;
import android.widget.ImageButton;
import com.jrr.flashlight.R;

public class Application extends Activity {

    ImageButton flashControl;
    Camera camera;
    Parameters params;

    private boolean hasFlash;
    private boolean isFlashOn = false;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.application_layout);

        flashControl = (ImageButton) findViewById(R.id.flashButtonOn);
        flashControl.setOnClickListener(flashControlListener());

        hasFlash = getApplicationContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH);  //sets value for boolean hasFlash

    }


    private View.OnClickListener flashControlListener() {
        return new View.OnClickListener(){
            @Override
            public …
Run Code Online (Sandbox Code Playgroud)

android imagebutton

14
推荐指数
3
解决办法
2万
查看次数

如何禁用asp:ImageButton的提交行为?

我在页面中有一个图像按钮,可以在鼠标点击时触发,默认情况下它会在按下时触发我也要禁用.

我知道asp:Button中的"UseSubmitBehaviour"属性,有没有办法在asp:ImageButton中做同样的事情?

asp.net imagebutton

12
推荐指数
2
解决办法
2万
查看次数

使用OnTouchListener时,如何更改Android中ImageButton上的图像?

我有以下代码创建一个ImageButton并在单击时播放声音:

ImageButton SoundButton1 = (ImageButton)findViewById(R.id.sound1);
SoundButton1.setImageResource(R.drawable.my_button);

SoundButton1.setOnTouchListener(new OnTouchListener() {
    public boolean onTouch(View v, MotionEvent event) {
        if (event.getAction() == MotionEvent.ACTION_DOWN ) {
            mSoundManager.playSound(1);
            return true;
        }

        return false;
    }
});
Run Code Online (Sandbox Code Playgroud)

问题是我希望按下它时ImageButton上的图像会发生变化.OnTouchListener似乎覆盖了触摸并且不允许图像更改.一旦我删除了OnTouchListener,ImageButton会在按下时切换到不同的图像.关于如何在仍然使用OnTouchListener时在ImageButton上更改图像的任何想法?非常感谢你!

android imagebutton

12
推荐指数
2
解决办法
5万
查看次数

如何在android中创建图像按钮?

所以我是android开发的新手......如何创建一个像按钮一样的图像,所以当我按下该图像时,图像会启动一个特定的活动.所以我希望这个显示为图像:

 <Button
    android:id="@+id/button1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_marginTop="33dp"
    android:text="Button" />
Run Code Online (Sandbox Code Playgroud)

java android button imagebutton android-activity

12
推荐指数
1
解决办法
4万
查看次数

Android ImageButton背景色

我有一个ImageButton,背景图像有一些透明度.默认情况下,由于Holo.Light主题,按钮会获得透明像素所在的灰色背景.我尝试通过该setBackgroundColor(Color.TRANSPARENT)方法将按钮的背景颜色设置为透明.这很好,并且做我需要的东西,除了现在我的按钮在聚焦/按下时不再具有浅蓝色并且看起来相当平坦(没有边框,所以它看起来像图像).

我用google搜索,看到你可以像这里解释的那样分配选择器,但这意味着我必须指定每个按钮状态的图像,我不想这样做.我想继承主题中的焦点/按下的颜色,但是将正常的按钮背景(未按下/聚焦时)覆盖为透明而不是灰色.我怎么能实现那个?请提供一个工作示例,因为我尝试了许多不同的组合但没有成功.

编辑 谢谢大家的帮助.我想出了如何使这项工作无需为每个按钮重新创建具有聚焦和按下状态的相同图像!

这是我的解决方案:

我的按钮定义为:

<ImageButton
            android:id="@+id/ImageButton05"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:background="@drawable/button" />
Run Code Online (Sandbox Code Playgroud)

我的后台XML文件(标题为button.xml)定义如下:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:state_pressed="true">
        <layer-list>
            <item android:drawable="@drawable/btn_default_pressed_holo_light"></item>
            <item android:drawable="@drawable/network_wifi"></item>
        </layer-list>
    </item>
    <item android:state_focused="true">
        <layer-list>
            <item android:drawable="@drawable/btn_default_focused_holo_light"></item>
            <item android:drawable="@drawable/network_wifi"></item>
        </layer-list>
    </item>
    <item android:state_hovered="true">
        <layer-list>
            <item android:drawable="@drawable/btn_default_focused_holo_light"></item>
            <item android:drawable="@drawable/network_wifi"></item>
        </layer-list>
    </item>
    <item>
        <layer-list>
            <item android:drawable="@drawable/btn_default_normal_holo_light"></item>
            <item android:drawable="@drawable/network_wifi"></item>
        </layer-list>
    </item>
</selector>
Run Code Online (Sandbox Code Playgroud)

android background imagebutton android-widget

12
推荐指数
1
解决办法
2万
查看次数

Android - 自动覆盖触摸/突出显示图像按钮状态

是否可以使用ImageButton来触摸和突出显示状态,而不需要在Android上再增加2个图像资源(另外6个,考虑到h/m/ldpi)?我基本上都在寻找类似于iOS的行为,其中操作系统可以在按钮的触摸状态下放置半alpha覆盖.

我已经尝试setColorFilter(0xFF000000, Mode.MULTIPLY)在onTouch监听器中使用,结果与我之后的结果非常接近 - 但我不确定状态处理的最佳方式来实现这一点:

  1. touchDown事件 - >更改颜色叠加.
  2. touchUp event - >删除颜色叠加,并执行按钮操作.

有更好的方法......或者有人可以帮助填补空白吗?

我不想使用单独的图像有几个原因 - 它是一个iPhone端口,我还没有适当的资产,并且需要更多的设计师时间考虑我有低/中/高创意到考虑.

谢谢!

android overlay imagebutton

11
推荐指数
1
解决办法
1906
查看次数

Android buttonimage摇动画

我是新的android和我正在寻找一种方法来点击我的按钮图像.到目前为止,我得到了这个,但它一直崩溃.或者,如果你点击它没有任何作用.我希望你们能帮助我.如果我忘了任何事情只是说出来.代码可能很乱.

我有一个动画文件夹.用shakeanim.xml

码:

activity_main.xml中

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"

    tools:context=".MainActivity" >

     <ImageButton
         android:id="@+id/imageButton1"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_centerHorizontal="true"
         android:layout_centerVertical="true"
         android:src="@drawable/chest"
        android:background="@null"/>

     <TextView
         android:id="@+id/textView1"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_above="@+id/imageButton1"
         android:layout_centerHorizontal="true"
         android:layout_marginBottom="51dp"
         android:text="100 Clicks" />

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

MainActivity.java

package com.example.egghatcher;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageButton;
import android.widget.TextView;


public class MainActivity extends Activity {

    ImageButton imageButton;

    TextView clicksToGo;

    Animation shake;

    private int clicks = 100;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        shake = …
Run Code Online (Sandbox Code Playgroud)

java xml android imagebutton shake

11
推荐指数
1
解决办法
1万
查看次数

UWP xaml:如何显示带有图标和文字的按钮?

如何在按钮中显示图像/图标和文字?

<StackPanel Name="stackPanel" Orientation="Horizontal" Tapped="stackPanel_Tapped">
    <Button x:Name="button" FontFamily="Segoe MDL2 Assets" Content="&#xE779;" Width="50" Height="50" Background="Transparent" />
    <TextBlock Text="Grades" FontSize="18" VerticalAlignment="Center" />
</StackPanel>
Run Code Online (Sandbox Code Playgroud)

我可以在stackpanel中添加一个taplistener,但这不会使stackpanel像真正的按钮一样具有视觉效果.

我也尝试过:

<Button FontFamily="Segoe MDL2 Assets" Width="50" Height="50" x:Name="button" Content="test">
   <Image x:Name="button" Source="Assets/test.png" />
</Button>
Run Code Online (Sandbox Code Playgroud)

但我不能两次设置内容.我想要一个按钮中的文本和图标,所以当用户点击它时,它将具有像按钮一样的视觉效果.这可能吗?或者其他人有其他方法来实现这一目标吗?

谢谢阅读.

xaml imagebutton uwp uwp-xaml

11
推荐指数
1
解决办法
1万
查看次数

如何在MVC 4中创建图像按钮

如何在MVC 4(Razor)中创建普通的旧图像按钮?我正在寻找这样的东西 在此输入图像描述

c# imagebutton razor asp.net-mvc-4

10
推荐指数
2
解决办法
3万
查看次数