我有TextView和autoLink功能的问题.
我的应用程序中有一个关于屏幕的信息,例如支持电话号码,电子邮件地址,网站URL和应用程序版本,如01.01.01
在textView上设置autoLink ="all"后,所有值都链接正常 - 除了版本号01.01.01也链接为电话号码.
有没有办法从链接中排除这个文本片段?
我有2个单选按钮,我想把它们放在一起.现在他们就像
Radio button 1
Radio button 2
Run Code Online (Sandbox Code Playgroud)
我想成功
Radio button 1 Radio button 2
Run Code Online (Sandbox Code Playgroud)
这是我的单选按钮代码,有什么帮助吗?
<RadioGroup
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RadioButton android:id="@+id/radio_male"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Male"
android:layout_below="@id/gender"/>
<RadioButton android:id="@+id/radio_female"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Female" />
</RadioGroup>
Run Code Online (Sandbox Code Playgroud) 我想在图像上放大图像单击事件.我怎样才能做到这一点.这是我的完整代码
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_height="fill_parent" android:layout_width="fill_parent" >
<LinearLayout android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button android:text="Button1" android:id="@+id/button1" android:layout_height="wrap_content" android:layout_width="wrap_content" ></Button>
<Button android:text="Button2" android:id="@+id/button2" android:layout_height="wrap_content" android:layout_width="wrap_content" ></Button>
<Button android:text="Button3" android:id="@+id/button3" android:layout_height="wrap_content" android:layout_width="wrap_content" ></Button>
</LinearLayout>
<LinearLayout android:orientation="horizontal"
android:layout_height="290dp"
android:layout_width="wrap_content"
android:layout_gravity="center_horizontal">
<ImageView android:id="@+id/contentImage"
android:layout_height="250dp"
android:layout_width="200dp"
/>
</LinearLayout>
<LinearLayout android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView android:id="@+id/imageView1" android:src="@drawable/img1" android:layout_height="75dp" android:layout_width="75dp" ></ImageView>
<ImageView android:id="@+id/imageView2" android:src="@drawable/img2" android:layout_height="75dp" android:layout_width="75dp" ></ImageView>
<ImageView android:id="@+id/imageView3" android:src="@drawable/img3" android:layout_height="75dp" android:layout_width="75dp" ></ImageView>
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
听到我的主要文件Image.java将在其中处理事件
package com.example;
import android.app.Activity;
import android.graphics.Matrix;
import android.graphics.PointF;
import android.os.Bundle; …Run Code Online (Sandbox Code Playgroud) 在我的Android模拟器上发生了奇怪的事情(代码和模拟器在API级别10上运行 - 是Android 2.3.3):我的emu上的当前日期是22.08.2011 - 如果我用这些设置初始化DatePickerDialog(使用新的值) Date() - 使用当前日期/时间初始化Date)然后失败,但有以下异常:
08-22 02:14:23.731: ERROR/AndroidRuntime(3038): FATAL EXCEPTION: main
08-22 02:14:23.731: ERROR/AndroidRuntime(3038): java.lang.IllegalArgumentException: current should be >= start and <= end
08-22 02:14:23.731: ERROR/AndroidRuntime(3038): at android.widget.NumberPicker.setCurrent(NumberPicker.java:288)
08-22 02:14:23.731: ERROR/AndroidRuntime(3038): at android.widget.DatePicker.updateSpinners(DatePicker.java:357)
08-22 02:14:23.731: ERROR/AndroidRuntime(3038): at android.widget.DatePicker.init(DatePicker.java:352)
08-22 02:14:23.731: ERROR/AndroidRuntime(3038): at android.app.DatePickerDialog.<init>(DatePickerDialog.java:127)
08-22 02:14:23.731: ERROR/AndroidRuntime(3038): at android.app.DatePickerDialog.<init>(DatePickerDialog.java:86)
Run Code Online (Sandbox Code Playgroud)
所以我检查了DatePicker的源代码(对于API lvl 2.3.3),我检查了DatePicker代码(因为从我知道它在updateSpinners方法中失败的strack跟踪)和那条线357(上面的堆栈中的第四行) trace)它调用mYearPicker.setCurrent(mYear); 这让我觉得我的一年有些不对劲.我记录了我过去的那一年 - 这是2011年的预期.所以我手动通过了2010年而不是有效 - DatePickerDialog出现了 - 初始化为2010年(太糟糕了,我真的需要当年 - 2011年;)......).
我有点不知道原因是什么...我的模拟器上的日期 - 如上所述 - 正确设置为22.08.2011 - 我的开发PC设置为同一天...
关于我哪里出错的任何线索/想法?为了方便起见,我在初始化DatePickerDialog的代码片段:
// Initializes a …Run Code Online (Sandbox Code Playgroud) android datepicker android-widget android-datepicker android-sdk-2.3
这是我在Stackoverflow上的第一篇文章.在我提出问题之前,我只想说这是一个很好的信息资源,我发现社区非常有帮助.我希望能够与其他人分享我的Android开发知识.
我已经为Android开发了6个月了,虽然我学到了很多东西,但在布局/设计方面我仍然非常努力.
我有一个包含相对布局的layout.xml文件.在这个布局中,我有三个按钮.我希望这三个按钮具有一定的宽度尺寸,根据设备的屏幕尺寸/密度增大或缩小.
这是xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relativeLayout1123123213"
android:layout_width="fill_parent"
android:layout_height="@dimen/actionbar_height"
android:orientation="horizontal">
<Button
android:id="@+id/btnLogin"
android:layout_width="100dp"
android:layout_height="50dp"
android:background="@drawable/button"
android:drawableLeft="@drawable/balloon_overlay_close"
android:gravity="center"
android:text="Earned" />
<Button
android:id="@+id/btnLogin2"
android:layout_width="113dp"
android:layout_height="50dp"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/btnLogin"
android:background="@drawable/button"
android:drawableLeft="@drawable/balloon_overlay_close"
android:gravity="center"
android:text="In Progress" />
<Button
android:id="@+id/btnLogin3"
android:layout_width="107dp"
android:layout_height="50dp"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/btnLogin2"
android:background="@drawable/button"
android:drawableLeft="@drawable/balloon_overlay_close"
android:gravity="center"
android:text="Done" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
考虑到每个按钮中有不同的文字大小,我对宽度值进行了硬编码...所以这显然也应该影响宽度......
我的问题是......是否有任何明智的方法来实现这一目标?也许以编程方式,当我知道当前设备的屏幕尺寸?
感谢大家!费利佩
================================================== ==更新的部分
嘿伙计们,感谢你们的帮助.
我根据建议添加了LinearLayout和重量,但我仍然没有得到我想要的东西.它几乎就在那里,但并不完全.
我的新xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="@dimen/actionbar_height"
android:orientation="horizontal"
android:gravity="center" android:weightSum="1">
<Button
android:id="@+id/btnLogin"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@drawable/button"
android:drawableLeft="@drawable/balloon_overlay_close"
android:gravity="center"
android:text="@string/bottonbar_earned"
android:layout_weight=".10"/>
<Button
android:id="@+id/btnLogin2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".10"
android:background="@drawable/button"
android:drawableLeft="@drawable/balloon_overlay_close"
android:gravity="center"
android:text="@string/bottonbar_inprogress" />
<Button
android:id="@+id/btnLogin3"
android:layout_width="0dp" …Run Code Online (Sandbox Code Playgroud) 我创建了一个画布.我在画布上画文字.但是当我在不同版本的android上测试时,文本看起来不同.版本4.х和2.2之间的区别.
Bitmap btmText = Bitmap.createBitmap(140, 90, Bitmap.Config.ARGB_4444);
Canvas cnvText = new Canvas(btmText);
Typeface tf = tf = Typeface.createFromAsset(context.getAssets(),"fonts/font.ttf");
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setSubpixelText(true);
paint.setTypeface(tf);
paint.setTextSize(50);
cnvText.drawText(text, 0, 5, 0, 55, paint);
Run Code Online (Sandbox Code Playgroud)
android 2.2上的文字看起来比android 4.0.3更大.
我知道如何通过调用动态地分配ID setID().由于ID是唯一的,我曾经使用ids.xml并setID()从预先生成的ID池中传递给ID.
问题1:有没有办法在不使用的情况下分配ID,ids.xml因为我无法预测运行时需要多少ID?
我试图绕过问题1中提出的第一个问题,动态分配每个基于其标签的哈希值的ID(每个标签都是唯一的),但没有办法保证ID不会与ID的自动生成冲突R.java.
问题1.1:如何解决ID命名冲突?
问题2:假设我具有动态分配和生成的ID值.由于未出现上述ID R.id,findViewById()因此不适用于检索视图.因此,当ID已知时,如何检索视图?
答案2:只有在onCreate()返回控制(终止)后,才能通过相应的ID检索视图.
好吧问题是我在我的活动中使用了一种SurfaceView,我想在其中添加按钮.
我的问题是:
1)如何在不调用findViewById(...)的情况下创建按钮实例?(因为surfaceView因为我没有布局)...
2)我如何在画布上绘制这个按钮?
或者你可能在建议做别的事情?
所有我关心的是我的屏幕上会有按钮,我可以实现像OnClickListener(...)....
谢谢所有提前!
我有一个带有大量文本视图的android程序.最初,所有这些视图都没有阴影.
当我按下一个特定的切换按钮时,我希望这些textViews能够脱颖而出.
理想情况下,我想为它们添加文本阴影发光效果.我已成功完成textView.setShadowLayer(radius,dx,dy,color)的问题
问题是,如果我再次按下相同的切换按钮(这会使阴影出现),我需要删除阴影,使文本不再突出显示.
我试图将阴影层设置为半径0和透明颜色#00FFFFFF,#00000000和颜色#FFFFFFFF,#FF000000.但是,这些都没有将textView设置回它出现的原始方式.
关于如何去除阴影的任何想法.(我真的不需要删除它,我只想让文本显示与添加之前相同的方式)
主要目标是使用切换按钮打开/关闭特定textViews的文本突出显示,我对其他方法开放,而不是使用阴影.理想情况下,我想使用阴影,但突出文本的任何其他想法都很好.
(这部分是在我收到textLayer.setShadow(0,0,0,0)的答案之后追加的;
我在布局xml中使用此样式的textView
<style name="second">
<item name="android:textColor">@drawable/buttonBabyBlue</item>
<item name="android:textStyle">bold</item>
<item name="android:textSize">@dimen/second_text_size</item>
<item name="android:lines">1</item>
<item name="android:background">@drawable/baseGray</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">0dip</item>
<item name="android:layout_weight">8.5</item>
<item name="android:gravity">bottom|left</item>
<item name="android:layout_gravity">bottom</item>
</style>
Run Code Online (Sandbox Code Playgroud)
当我按下按钮,使视图有阴影
text.setShadowLayer(GLOW_RADIUS, GLOW_DX, GLOW_DY, R.drawable.buttonBabyBlue);
text.setTextColor(R.drawable.baseGray);
Run Code Online (Sandbox Code Playgroud)
然后删除阴影
text.setShadowLayer(0, 0, 0, 0);
text.setTextColor(R.drawable.buttonBabyBlue);
Run Code Online (Sandbox Code Playgroud)
这很烦人我有图片显示和上传他们但他们不会让我显示它们,因为害怕垃圾邮件
在我的Android应用程序中,需要禁用许多UI元素,直到按钮单击执行.我可以通过引用布局来禁用布局中的所有UI元素,而不是逐个禁用它们.有可能.可以帮助我一些人.
android ×10
android-widget ×10
android-view ×1
datepicker ×1
radio-button ×1
textview ×1
xml ×1