小编Pla*_*eon的帖子

如何绘制布局时如何判断?

我有一个自定义视图,可以将可滚动的位图绘制到屏幕上.为了初始化它,我需要传递父布局对象的像素大小.但是在onCreate和onResume函数期间,尚未绘制布局,因此layout.getMeasuredHeight()返回0.

作为一种解决方法,我添加了一个处理程序等待一秒然后测量.这是有效的,但它很草率,我不知道在布局绘制之前我能在多长时间内缩短时间.

我想知道的是,如何检测布局何时被绘制?有事件或回调吗?

android android-layout

194
推荐指数
5
解决办法
11万
查看次数

是否可以在android中屏蔽View?

是否可以屏蔽视图?例如,如果我有一个设计,要求列表视图在椭圆形开口内可见.有没有办法为视图创建蒙版?它被称为其他东西吗?因为我发现在android文档中屏蔽的所有引用都在谈论屏蔽画布对象或drawable.但我不认为像列表视图这样的交互式对象的绘制是一种很好的方法.这只是现在处理的限制吗?

android

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

Android应用内安全建议 - 这是什么意思?

Android开发人员说如下关于在项目中存储应用程序公钥:

安全建议:强烈建议您不要对Google Play提供的确切公共许可证密钥字符串值进行硬编码.相反,您可以在运行时从子字符串构造整个公共许可证密钥字符串,或者在将其传递给构造函数之前从加密存储中检索它.这种方法使恶意第三方更难以修改APK文件中的公共许可证密钥字符串.

这应该是不言自明的吗?我不明白他们要我做什么.

他们在这个例子的评论中说了同样的话,但他们实际上并没有通过他们的指示来证明他们的意思.这就是它所说的:

不是仅将整个文字字符串存储在*程序中,而是在运行时从片段构造键或使用位操作(例如,使用其他字符串的XOR)来隐藏*实际键.密钥本身不是秘密信息,但我们并不希望攻击者能够轻松地用自己的一个*替换公钥,然后从服务器替换伪造的消息.

那么一个人究竟怎么做到这一点呢?

security android public-key-encryption

8
推荐指数
1
解决办法
1586
查看次数

将 Google Sheets 自动化到 strings.xml 以进行本地化

我有一个包含所有 strings.xml 资源翻译的 Google 表格。每种语言都是一列。第一列是字符串资源 ID。

您是否知道我可以使用的工具(或宏或任何东西)可以让我将电子表格重新导出为具有适当区域后缀的 strings.xml 格式?(后缀是电子表格的第一行。)

android google-sheets

5
推荐指数
1
解决办法
3490
查看次数

将Javascript命名空间设置为Window:不好主意?还是很棒?

我在EaselJS库的示例中讨论了这段代码 - 它的作用是将整个createjs库的命名空间分配给"window".

<script>
var createjs = window;
</script>
Run Code Online (Sandbox Code Playgroud)

我的问题是:设置一个库的命名空间窗口是一个非常愚蠢的想法?是不是通过使所有命名空间变量突然全局范围来摆脱使用命名空间的全部意义?

我能看到的唯一优势是让你为你的对象编写更短的构造函数.例如输入:

 stage = new Stage(canvas);
Run Code Online (Sandbox Code Playgroud)

代替:

 stage = new  createjs.Stage(canvas);
Run Code Online (Sandbox Code Playgroud)

这是一个坏主意,还是某种程度上很棒,或者只是无害的古怪?

javascript createjs

5
推荐指数
2
解决办法
451
查看次数

为什么Eclipse会告诉我LinearLayout没有属性"margin"?

我尝试构建我的android项目时遇到错误:

在'android'包中找不到属性'margin'的资源标识符

它引用这种布局作为罪魁祸首.但我发现它没有任何问题.

任何想法为什么Eclipse会认为这些视图上没有保证金有利润?

<?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:layout_margin="5dp"
    android:background="@color/feedstory_background_color"
    android:margin="5dp"
    android:orientation="vertical"
    android:padding="5dp" >

    <RelativeLayout
        android:id="@+id/feed_profile_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="5dp" >

        <ImageButton
            android:id="@+id/feed_profileImage"
            android:layout_width="60dp"
            android:layout_height="60dp"
            android:layout_alignParentLeft="true"
            android:layout_margin="0dp"
            android:background="@color/black_bg"
            android:maxHeight="60dp"
            android:maxWidth="60dp"
            android:padding="1dp"
            android:scaleType="centerInside"
            android:src="@drawable/feed_blank_profile_picture" />

        <LinearLayout
            android:id="@+id/profile_texts"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="5dp"
            android:layout_marginLeft="5dp"
            android:layout_toRightOf="@id/feed_profileImage"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/profile_name_text"
                style="@style/feed_profile_name"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/feed_profile_name" >
            </TextView>

            <TextView
                android:id="@+id/profile_location_text"
                style="@style/feed_profile_location"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/feed_profile_location" >
            </TextView>

            <TextView
                android:id="@+id/profile_time_text"
                style="@style/feed_profile_time"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/feed_profile_time" >
            </TextView>
        </LinearLayout>

        <LinearLayout
            android:id="@+id/profile_texts"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:orientation="vertical" >

            <Button
                android:id="@+id/fan_button"
                style="@style/feed_button_text" …
Run Code Online (Sandbox Code Playgroud)

android adt android-layout

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