小编yat*_*at0的帖子

使用android:elevation在LinearLayout上投射阴影

我有这个LinearLayout将被放置在活动布局的底部.我希望它LinearLayout具有4dp高程,就像顶部工具栏应该具有的那样,但是,因为android:elevation将阴影置于ui组件下方并且此特定组件(linearLayout)将位于屏幕的底部,我将看不到任何高度......

这是我的LinearLayout代码,以及实现默认高程的图像:

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:weightSum="3"
    android:background="@android:color/transparent"
    android:orientation="horizontal"
    android:elevation="4dp"
    android:layout_alignParentBottom="true">

    <ImageButton
        android:id="@+id/playButton"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:scaleType="center"
        android:clickable="true"
        android:background="@drawable/bottom_toolbar_menu_selector"
        android:src="@drawable/ic_play"
        style="?android:attr/borderlessButtonStyle" />

    <ImageButton
        android:id="@+id/stopButton"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:scaleType="center"
        android:clickable="true"
        android:background="@drawable/bottom_toolbar_menu_selector"
        android:src="@drawable/ic_stop"
        style="?android:attr/borderlessButtonStyle" />

    <ImageButton
        android:id="@+id/bookmarkButton"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:scaleType="center"
        android:clickable="true"
        android:background="@drawable/bottom_toolbar_menu_selector"
        android:src="@drawable/ic_bookmark"
        style="?android:attr/borderlessButtonStyle" />

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

有没有办法,使用elevation阴影放在ui组件的顶部? 提前致谢!

android android-layout material-design android-5.0-lollipop

28
推荐指数
1
解决办法
2万
查看次数

创建自定义BigDecimal类型

在我的应用程序中,所有BigDecimal数字都缩放为两位小数.换句话说,每次我在代码中创建一个新的BigDecimal时,我也需要使用方法比例:

BigDecimal x = BigDecimal.ZERO;
x.setScale(2, RoundingMode.HALF_UP);
Run Code Online (Sandbox Code Playgroud)

因此,为了最大限度地减少工作量,我想创建自定义BigDecimal类型,例如:

public class CustomBigDecimal extends BigDecimal {

    public CustomBigDecimal(String val) {
        super(val);
        this.setScale(2, RoundingMode.HALF_UP);
    }

}
Run Code Online (Sandbox Code Playgroud)

我知道this.setScale(2, RoundingMode.HALF_UP);不做这项工作,但我找不到办法,是否有可能?

java bigdecimal

16
推荐指数
3
解决办法
2343
查看次数

操作栏溢出菜单项不会出现

我刚刚完成了一个测试应用程序,我希望在2.1的所有Android设备中得到支持,所以我使用支持库来支持操作栏,但我在设备上遇到了问题,但是我在Android 2.3 ...似乎很好,操作栏和我选择显示"ifRoom"的所有itens正在出现但溢出下降itens菜单丢失,我真的不知道为什么.3.0以下的Android设备是否支持此溢出菜单或什么?

第二个活动中有我的xml代码:

<menu xmlns:android="http://schemas.android.com/apk/res/android" 
  xmlns:teste="http://schemas.android.com/apk/res-auto" >

<item android:id="@+id/action_search"
    android:showAsAction="ifRoom"
    teste:showAsAction="ifRoom"
    android:icon="@drawable/ic_action_search"
    android:title="@string/action_search" />

<item android:id="@+id/action_edit"
    android:showAsAction="ifRoom"
    teste:showAsAction="ifRoom"
    android:icon="@drawable/ic_action_edit"
    android:title="@string/action_edit" />

<item
    android:id="@+id/action_settings"
    android:showAsAction="never"
    teste:showAsAction="never"
    android:title="@string/action_settings" />
Run Code Online (Sandbox Code Playgroud)

有人可以帮我吗?ps:对不起英语不好

android

3
推荐指数
1
解决办法
1336
查看次数

保护私有 API 密钥

所以我一直在搜索关于整个私有 API 密钥安全性的一段时间,我对我应该采取的方法感到有些困惑,因为我还没有找到与我有相同特定问题/方法的人。

我正在开发一个通过第三方 API 运行的 Android 应用程序,我通过请求私钥获得了访问权限。现在,2点:

  • 我的应用程序不直接请求我正在使用的 API,而是请求一组 PHP 文件(托管在应用程序网站上)我编码以简化请求并从我正在使用的 API 中检索数据,让如果您允许,则称其为“某种 API”。因此,从应用程序只发送指定我的 API 类型应该请求原始 API 的请求,因此,请求不需要原始 API 私钥,因为我可以将它存储在其中一个php 文件并在需要时使用。
  • 我的应用程序不需要用户注册他们的帐户,所以我没有任何用户 ID 或名称可以用于请求。

因此,从这里您可以看到,我并没有尝试在应用程序代码中隐藏 API 密钥,也没有尝试使用用户 ID 和签名来允许访问我的类型的 API 并连续访问原始 API..

问题是,尽管无法在浏览器中看到 php 代码,但以其他方式这样做并非不可能,所以我在那里存储我的密钥也不安全。所以我的问题很简单,这仍然是我用来隐藏我的私有 API 密钥的最佳方法,还是我应该重新考虑我完成所有这些过程的方式?

php security api android key

3
推荐指数
1
解决办法
5276
查看次数