我在Android代码中将图像设置为ImageView而不是xml,但无法确定如何检查该图像是否已在java中设置.
试过imageViewOne.getVisibility() == 0
但它不起作用
如果图像已设置为ImageView,那么我将附加该图像以发送邮件.
我有一个布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF">
<TextView android:id="@+id/groupname"
android:paddingLeft="50px"
android:textSize="16px"
android:background="#FFFFFF"
android:textColor="#000000"
android:textStyle="normal"
android:layout_width="wrap_content"
android:layout_height="50px"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginRight="6dp"
android:background="#ffffff"
android:src="@drawable/sort"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

渲染现在正在发生,就像在第一张图像中一样,但我想像第二张图像一样完全右对齐.任何帮助都会有用.
期待你的回复.谢谢.
我们可以在旁边有一个谷歌语音操作按钮edittext,所以每当用户想要在edittext中输入内容时,他只需轻按按钮,说话并进入edittext.我们可以做那样的事情,而不是用户必须点击edittext打开软键盘选择语音操作按钮,然后说出哪些打印到edittext.
期待你的回复.
谢谢.
我有一个布局,我通过WebView在其中呈现HTML文档.
XML布局是
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:scrollbars="vertical">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/header"
android:layout_alignParentTop="true"
android:layout_width="fill_parent"
android:layout_height="30dip"
android:background="@drawable/black"
android:tileMode="repeat">
<ImageButton
android:id="@+id/btnBackHelp"
android:src="@drawable/greenarrow"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="@drawable/black"
android:tileMode="repeat"/>
<ImageView
android:src="@drawable/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_height="fill_parent"
android:layout_width="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_marginTop="30dip">
<WebView
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:id="@+id/helpBrowserWebview"/>
</LinearLayout>
<LinearLayout
android:layout_alignParentBottom="true"
android:layout_width="fill_parent"
android:layout_height="30dip"
android:layout_weight="1"
android:weightSum="5"
android:orientation="horizontal"
android:background="@drawable/black"
android:tileMode="repeat">
<LinearLayout
android:id="@+id/footerLayoutHome"
android:clickable="true"
android:layout_width="fill_parent"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center"
android:layout_height="fill_parent">
<ImageButton
android:id="@+id/footerMainBtnHome"
android:layout_width="fill_parent"
android:layout_height="14dip"
android:src="@drawable/home"
android:background="@drawable/black"/>
<TextView
android:text="Home"
android:textSize="8dip"
android:textColor="#ffffff"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:id="@+id/footerLayoutProducts"
android:clickable="true"
android:layout_width="fill_parent"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center" …Run Code Online (Sandbox Code Playgroud) 我在onClick上使用onClick来捕获图像.
PictureCallback myPictureCallback_JPG = new PictureCallback() {
@Override
public void onPictureTaken(byte[] arg0, Camera arg1) {
FileOutputStream outStream = null;
try {
// Write to SD Card
outStream = new FileOutputStream(String.format("/sdcard/%d.jpg", System.currentTimeMillis()));
outStream.write(arg0);
outStream.close();
Toast.makeText(Photo.this, "Image Saved to SD Card", Toast.LENGTH_SHORT).show();
System.out.println();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
camera.startPreview();
}};
Run Code Online (Sandbox Code Playgroud)
图像保存在SD卡中.然后用户单击"发送"按钮并打开布局,在"单击ImageView"上打开图像库并单击特定图像,将选择URI.
imageAttachPhoto = (ImageView)findViewById(R.id.imageViewPhotoOne);
imageAttachPhoto.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,"Select Picture"), SELECT_PICTURE);
} …Run Code Online (Sandbox Code Playgroud) 我有一个单击按钮的语音识别器意图。
voiceSearch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try{
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Speak Now...");
startActivityForResult(intent, REQUEST_CODE);
}
catch (ActivityNotFoundException e) {
Log.v("Speech", "Could not find any Speech Recognition Actions");
}
}
});
Run Code Online (Sandbox Code Playgroud)
在活动结果中,我的代码为
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
System.out.println("Request code++++++++++++++++++++++++++++"+requestCode);
System.out.println("Result Code+++++++++++++++++++++++++++++"+resultCode);
System.out.println("Data++++++++++++++++++++++++++++++++++++"+data);
System.out.println("Language"+data.getStringExtra(RecognizerIntent.EXTRA_LANGUAGE));
System.out.println("data.getDataString()"+data.getDataString());
if (requestCode == REQUEST_CODE && resultCode == RESULT_OK) {
if (data != null && data.getData() != null) {
String searchKey = data.getData().toString();
System.out.println("Search …Run Code Online (Sandbox Code Playgroud)