当用户在EditText中输入信息并移动到下一个EditText时,信息将突出显示,如下所示:

这个代码:
edittext.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
v.setBackgroundColor(Color.WHITE);
((EditText) v).setTextColor(Color.BLACK);
} else {
//v.setBackgroundColor(Color.LTGRAY); //also works like this
((EditText) v).setBackgroundColor(Color.LTGRAY);
((EditText) v).setTextColor(Color.BLACK);
}
}
});
Run Code Online (Sandbox Code Playgroud)
在这样的onCreate方法中调用:
edittext = (EditText) findViewById(R.id.editText1);
但是,如果背景颜色仅应用于文本本身而不是视图(例如来自gmail应用程序),那将会好得多:

有没有人对如何将背景颜色仅应用于文本(而不是整个EditText视图)有任何建议?
谢谢.
我正在制作一个基本的应用程序,用户可以在其中检查他们的“用餐余额”,我设法通过解析正确的网页来做到这一点。
我的应用程序工作得很好,但我发现当我退出它时,当前正在运行的应用程序屏幕(Android 应用程序管理器)在显示我的应用程序时变得非常慢,甚至滞后。
我尝试使用以下方法终止我的应用程序,以便应用程序在退出时不会在后台运行,但它不起作用:
@Override
protected void onStop() {
super.onStop();
android.os.Process.killProcess(android.os.Process.myPid());
System.exit(0);
}
@Override
public void onBackPressed() {
super.onBackPressed();
finish();
System.exit(0);
}`
Run Code Online (Sandbox Code Playgroud)
所以现在,我试图弄清楚为什么“当前应用程序”屏幕由于我的应用程序而变慢。我的应用程序没有在后台执行任何操作,它只是闲置。这里是新手。
我目前使用 Firebase JobDipatcher 在后台执行周期性任务。问题是后台服务仅在禁用电池优化并且应用程序的待机状态在开发人员选项下手动设置为 ACTIVE 时才会执行。有没有办法在不手动更改所有这些的情况下完成后台任务,因为我不能要求应用程序的每个用户都这样做。并看到许多帖子说如果在应用程序中请求电源管理权限,谷歌将暂停该应用程序。任何帮助将非常感激。
android alarmmanager android-background firebase-job-dispatcher android-workmanager
如何让活动像对话框一样出现在屏幕的中央,而前一个活动(调用透明的活动的活动)
在后台仍然可见?我尝试将重力设置为中心,将背景设置为#00000000,如其他答案所示,但它在其他答案中看不到.
transparency android android-layout android-activity android-background
我正在使用SlidingUpPanel.一切都很好.:)我想要实现的是将图像中面板的背景颜色更改为透明,以便显示其后面的图像部分.我尝试将SLidingPaneLayout的背景颜色设置为透明,但它不起作用.当我将颜色更改为红色等其他颜色时,它会显示红色但不会发生透明相同的颜色.
我也尝试将窗口背景设置为透明,但它留下了黑色背景.
Window window = this.getWindow();
window.setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
Run Code Online (Sandbox Code Playgroud)
请帮忙.

<?xml version="1.0" encoding="utf-8"?>
<com.app.custom.SlidingUpPanelLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:blurView="http://schemas.android.com/tools"
xmlns:sothree="http://schemas.android.com/apk/res-auto"
android:id="@+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
sothree:umanoDragView="@+id/dragView"
sothree:umanoPanelHeight="110dp"
sothree:umanoParalaxOffset="0dp"
sothree:umanoShadowHeight="0dp">
<!-- MAIN CONTENT -->
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/imgProfileLarge"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@null"
android:scaleType="centerCrop"
android:src="@drawable/profile" />
<RelativeLayout
android:id="@+id/layoutDetails"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="gone">
<com.app.custom.UnscrollableViewPager
android:id="@+id/facesPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true" />
<com.app.custom.CirclePageIndicator
android:id="@+id/indicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerInParent="true"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="10dp"
android:padding="10dp" />
</RelativeLayout>
</FrameLayout>
<!-- SLIDING LAYOUT -->
<com.app.custom.FrameLayoutWithBluredBackground
android:id="@+id/dragView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="false"
blurView:blurRadius="20">
<ViewFlipper
android:id="@+id/mViewFlipper"
android:layout_width="match_parent" …Run Code Online (Sandbox Code Playgroud) android android-layout android-sliding slidingmenu android-background
我是android的新手,在这里我的目标是使用警报管理器每2分钟运行一个代码段,该代码段将轮询服务器(使用网站的api),并基于返回的JSON生成通知。上网查找后,我认为最好的选择之一就是使用Intent服务和android。
服务和收据清单
<service
android:name=".NotifyService"
android:enabled="true"
android:exported="false" >
</service>
<receiver
android:name=".TheReceiver"
android:enabled="true"
android:exported="true" >
</receiver>
<receiver
android:name=".OnOffReceiver"
android:enabled="true"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)
在Flash屏幕活动的一部分中,我将其称为意图服务,该服务负责轮询通知:
Intent msgIntent = new Intent(this, NotifyService.class);
startService(msgIntent);
Run Code Online (Sandbox Code Playgroud)
接收器在设备启动时启动警报:
public class OnOffReceiver extends BroadcastReceiver
{
private AlarmManager alarmMgr;
private PendingIntent alarmIntent;
public OnOffReceiver(){}
@Override
public void onReceive(Context context, Intent intent)
{
Intent service = new Intent(context, NotifyService.class);
service.setAction(NotifyService.CREATE);
context.startService(service);
}
}
Run Code Online (Sandbox Code Playgroud)
IntentService类别
public class NotifyService extends IntentService
{
public NotifyService()
{
super("NotifyService");
}
public static final …Run Code Online (Sandbox Code Playgroud) android alarmmanager android-service intentservice android-background
嗨我正在使用自定义主题来自定义我的警报对话框.我的问题是,当我将背景颜色设置为任何颜色时,我的文本变得不可见.这是我的代码
<style name="CustomDialogFragment" parent="android:Theme.Dialog">
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:background">@color/black</item>
<item name="textColorAlertDialogListItem">@color/white</item>
</style>
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激,并提前感谢
android android-alertdialog android-dialogfragment android-styles android-background
android android-menu android-actionbar android-drawable android-background
我有一个简单LinearLayout的ImageView布局视图,法线视图的权重分别为0.55和0.45。
除非我给weightsum我的礼物,我不能分手LinearLayout。
有我的后LinearLayout裂开,我试图给一个背景色,以我的看法,但它不是反映。
下面是我的代码:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1"
>
<ImageView
android:layout_weight=".55"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="5dip"
android:scaleType="fitXY"
android:src="@drawable/ic_launcher_background"
android:contentDescription="TODO" />
<View
android:layout_weight=".45dp"
android:layout_width="match_parent"
android:layout_height="0dp"
android:visibility="visible"
android:background="@color/colorPrimary"
></View>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我不知道应该进行哪些更改,以便可以正确拆分视图并设置背景颜色。提前致谢!
android android-linearlayout android-background android-layout-weight
android ×9
alarmmanager ×2
android-menu ×1
background ×1
performance ×1
slidingmenu ×1
transparency ×1