我有一个后台线程休眠 1/10 秒,然后重新循环。我希望它使屏幕无效,因此它将重绘并执行简单的动画。似乎使屏幕无效的唯一方法是在 Runnable 中执行此操作,这假设有很多开销。
有没有一种方法可以在不使用可运行对象的情况下使线程内的屏幕无效?
我想在temprory内存中复制一些文本:
TextView tv = (int)findViewById(R.id.txt);
String str = tv.getText().toString();
Run Code Online (Sandbox Code Playgroud)
现在如何在剪贴板中复制str ???
如果我使用不属于Android 2.3.3 API的视图类(如setLayerType)的API,如何让我的Android应用程序与以前的Android版本兼容?我可以用这种方法代替什么?
大家好,为什么这段代码不起作用?我让 TextView 从 sqlite 数据库获取值,我想检查它是否为空隐藏 TextView。
mTel1 = (TextView) findViewById(R.id.tv_tel1);
String ed_text = mTel1.getText().toString().trim();
if(ed_text.length() == 0 || ed_text.equals("") || ed_text == null)
{
mTel1.setVisibility(View.VISIBLE);
}
else
{
mTel1.setVisibility(View.GONE);
}
Run Code Online (Sandbox Code Playgroud)
XML
<TextView
android:id="@+id/tv_tel1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="3dp"
android:background="@drawable/border"
android:clickable="true"
android:padding="10dp"
android:textColor="#0066cc"
android:textSize="18sp" />
Run Code Online (Sandbox Code Playgroud) 我已经创建了代码,当我点击假设一个图像时,B图像应显示100毫秒,然后关闭
我是通过Java Code完成的
public void changeRightDrum() {
System.out.println("RIGHT");
imageViewB.setVisibility(View.VISIBLE);
try {
Thread.sleep(100);
} catch (Exception e) {
e.printStackTrace();
}
imageViewB.setVisibility(View.GONE);
System.out.println("RIGHT DONE");
}
Run Code Online (Sandbox Code Playgroud)
但它不工作B图像不显示
任何人都可以帮助我如何实现这一目标
你好,我有这个简单的观点:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/lavagna_verticale"
android:orientation="vertical" >
<TextView
android:id="@+id/voto_lavagna"
android:layout_width="235sp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:gravity="center"
android:textColor="@color/bianco"
android:textSize="30sp"
android:textStyle="bold"/>
</RelativeLayout>Run Code Online (Sandbox Code Playgroud)
我可以将图像显示到背景中,但需要进行 lint 检查:
Possible overdraw: Root element paints background @drawable/lavagna_verticale with a
theme that also paints a background (inferred theme is @android:style/Theme.Holo)Run Code Online (Sandbox Code Playgroud)
我创建了一种新风格:
<style name="SfondoLavagnaVerticale" parent="@style/Theme.AppCompat">
<item name="android:background">@drawable/lavagna_verticale</item>
</style>Run Code Online (Sandbox Code Playgroud)
并改变我的看法:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:theme="@style/SfondoLavagnaVerticale"
android:orientation="vertical" >
..
....
.....Run Code Online (Sandbox Code Playgroud)
现在我没有 lint 错误,但我无法显示我的图像我能做什么?
我想显示一种颜色供用户预览。View我应该使用哪个?
我想要一个小方块,比如说,100dp。
我让一位朋友测试我的应用程序,但他注意到布局存在一些奇怪的问题。列表视图中的所有视图都将悬停在操作栏上。
问题是,我无法在我自己的设备或模拟器上重现这个,所以我假设它特定于某些版本的 Android?有谁知道这里的问题
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.brainicism.summonertracker.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_main" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
android:src="@drawable/ic_add" />
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
content_main.xml
<LinearLayout 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:orientation="vertical"
android:paddingBottom="0dp"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity">
<ListView
android:id="@+id/trackingList"
android:layout_width = "match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
主要活动
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
Run Code Online (Sandbox Code Playgroud)
android android-appcompat android-layout android-view android-actionbar
是否有任何备用侦听器可用于在y轴上获取滚动量?
我正在使用android.support.v7.widget.Toolbar但它没有API级别19的向后兼容性.
View.setPivotX(float value)
Run Code Online (Sandbox Code Playgroud)
起初我以为这个方法以“百分比”作为输入,其中0f代表左边缘,1f代表右边缘。
然而,经过测试,并非如此。而且从文档来看,虽然不是很清楚,但看起来我们需要传入一个像素的绝对位置。
我试过了,view.setPivotX(view.getRight())但结果不是我所期望的。视图变成了屏幕外。
那么......我如何正确地将视图旋转到其右边缘?(底部边缘相同,对于 PivotY)
PS请注意,我不是为了执行动画而要求的,我只是想按一定比例缩小视图的大小。