textview的最后一行略有截止.切断较大和较低的字母(g,j,y ...).我找到或尝试过的解决方案都没有,比如添加填充,边距,删除layout_gravity ......这在更改文本和设置多行时发生,而不是使用默认字符串.
下面的代码在FrameLayout中.
<RelativeLayout
android:id="@+id/window"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/black">
<RelativeLayout
android:id="@+id/action_bar"
android:layout_alignParentTop="true"
android:layout_width="fill_parent"
android:layout_height="46dp"
android:background="@color/royal_blue" >
<ImageView
android:id="@+id/imageView"
android:layout_width="38dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_gravity="center_vertical|left"
android:layout_margin="4dp"
android:background="@drawable/ic_launcher" />
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:id="@+id/space"
android:background="@color/royal_blue"
android:layout_toLeftOf="@+id/selectLeft"
android:layout_toRightOf="@+id/imageView" />
<Button
android:id="@+id/buttonOptions"
style="?android:attr/buttonStyleSmall"
android:layout_width="33dp"
android:layout_height="33dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_gravity="center_vertical|center_horizontal"
android:background="@drawable/ic_action_overflow"
android:gravity="right" />
<TextView
android:id="@+id/selectLeft"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_toLeftOf="@+id/selectRight"
android:layout_marginRight="4dp"
android:gravity="center"
android:textColor="@color/white"
android:textSize="20sp" />
<TextView
android:id="@+id/selectRight"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_toLeftOf="@+id/buttonOptions"
android:layout_marginRight="2dp"
android:layout_marginLeft="4dp"
android:gravity="center"
android:textColor="@color/white"
android:textSize="20sp" />
</RelativeLayout>
<View
android:id="@+id/action_bar_shadow"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_below="@+id/action_bar"
android:background="@color/darker_blue" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="4dp" …Run Code Online (Sandbox Code Playgroud) 我想实现切换火炬功能.因此,相机不会被捕获并崩溃 - 就像Lollipop一样 - 我正在尝试使用setTorchModeAPI 23.我有一个代码实现来打开或关闭火炬; 但是,我不知道如何检查闪光灯的当前状态.
CameraManager manager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);
try {
String[] cameras = manager.getCameraIdList();
for (int i = 0; i < cameras.length; i++) {
CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameras[i]);
boolean flashAvailable = characteristics.get(CameraCharacteristics.FLASH_INFO_AVAILABLE);
if (flashAvailable) {
boolean flashState = getFlashState(); //MISSING METHOD
manager.setTorchMode(cameras[i], !flashState);
}
}
} catch (CameraAccessException e) {
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
那么,如何在getFlashState不使用旧相机API的情况下实现?是否可以在不拍摄相机的情况下完成?
我有一个透明的黑色背景视图:#DD000000
我想要的是,在某些情况下,视图从#223333FF转换回第一种颜色.
//lastApp.setBackgroundColor(getResources().getColor(R.color.semitransparent));
ColorDrawable[] color = {new ColorDrawable(Color.BLUE), new ColorDrawable(Color.BLACK)};
TransitionDrawable trans = new TransitionDrawable(color);
int sdk = android.os.Build.VERSION.SDK_INT;
if(sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) {
lastApp.setBackgroundDrawable(trans);
} else {
lastApp.setBackground(trans);
}
trans.startTransition(300);
Run Code Online (Sandbox Code Playgroud)
这段代码有效,但颜色不是我想要的颜色.
如果我使用下一行,我相信它会创建两种黑色,因为我没有看到任何蓝色,并且透明度丢失了.
ColorDrawable[] color = {new ColorDrawable(getResources().getColor(R.color.blue)), new ColorDrawable(getResources().getColor(R.color.black_overlay))};
Run Code Online (Sandbox Code Playgroud)
我的下一次尝试是使用没有alpha的资源:#DD000000 - >#000000; #223333FF - >#3333FF这里的过渡有效,但不是我想要的,因为没有透明度.
接下来的两个尝试只是尝试新的东西,因为我想使用颜色资源.
下一行,我得到一个没有透明度的黑色.
ColorDrawable[] color = {new ColorDrawable(0x223333FF), new ColorDrawable(0xDD000000)};
Run Code Online (Sandbox Code Playgroud)
这导致最终的蓝色,而不是透明的黑色
ColorDrawable[] color = {new ColorDrawable(0x223333FF), new ColorDrawable(0x33000000)};
Run Code Online (Sandbox Code Playgroud)
我也尝试过,没有效果:
color[1].setAlpha(50);
Run Code Online (Sandbox Code Playgroud)
那么,我做错了什么?或者有更好的方法来实现这一目标吗?