标签: android

如何在滚动视图中设置谷歌地图片段

我想设置内垂直一个谷歌地图片段ScrollView,当我做的地图不垂直缩放,我怎么可以覆盖触摸事件监听器MapView上的监听器ScrollView

这是我的xml代码:

  <ScrollView  android:layout_height="wrap_content"
    android:layout_width="fill_parent"
     android:layout_above="@id/footer"
    android:layout_below="@id/title_horizontalScrollView">

   ///other things



<fragment 
    android:id="@+id/map"
    android:layout_width="fill_parent"
    android:layout_height="300dp"
    class="com.google.android.gms.maps.SupportMapFragment"
    />

  //other things
Run Code Online (Sandbox Code Playgroud)

android google-maps android-fragments

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

扩展类android.support.design.widget.CoordinatorLayout时出错

我想在我的应用程序上使用FloatingActionButton,我读到这个:https://guides.codepath.com/android/Floating-Action-Buttons#google-s-official-support-library但是当我运行Activity我有这个错误:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xavier_laffargue.podcast/com.xavier_laffargue.podcast.ACT_Test}: android.view.InflateException: Binary XML file line #1: Error inflating class android.support.design.widget.CoordinatorLayout
Run Code Online (Sandbox Code Playgroud)

XML文件

<android.support.design.widget.CoordinatorLayout
    android:id="@+id/main_content"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ListView
        android:id="@+id/lvToDoList"
        android:layout_width="match_parent"
        android:layout_height="match_parent"></ListView>

    <android.support.design.widget.FloatingActionButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|right"
        android:layout_margin="24dp"
        android:src="@drawable/ic_action_refresh"
        app:layout_anchor="@id/lvToDoList"
        app:layout_anchorGravity="bottom|right|end" />

</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)

Graddle

*apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.xavier_laffargue.podcast"
        minSdkVersion 21
        targetSdkVersion 20
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile …
Run Code Online (Sandbox Code Playgroud)

android floating-action-button

36
推荐指数
6
解决办法
6万
查看次数

运行Android应用程序时出错 - 无法初始化OpenglES仿真,请使用'-gpu off'禁用它

我是android编程的新手.我指的是google开发者网站,以学习android.当我运行应用程序UI时,我遇到了这些错误.

 H:\SDK\tools\emulator.exe -avd Nexus_5_API_21_x86 -netspeed full -netdelay none
 emulator: ERROR: Could not initialize OpenglES emulation, use '-gpu off' to   disable it.
 could not get wglGetExtensionsStringARB
 could not get wglGetExtensionsStringARB
 could not get wglGetExtensionsStringARB
 could not get wglGetExtensionsStringARB
 could not get wglGetExtensionsStringARB
 could not get wglGetExtensionsStringARB
 could not get wglGetExtensionsStringARB
 could not get wglGetExtensionsStringARB
 getGLES1ExtensionString: Could not find GLES 1.x config!
 Failed to obtain GLES 1.x extensions string!
 Could not initialize emulated framebuffer
Run Code Online (Sandbox Code Playgroud)

我正在使用android studio.

android android-virtual-device android-layout android-fragments android-activity

36
推荐指数
3
解决办法
9万
查看次数

Android Studio:"libpng警告:iCCP:无法识别已编辑的已知sRGB配置文件"

我花了几个小时试图解决这个问题:

app:mergeDebugResources AAPT err(927129865):C:\ Users\Will\AndroidStudioProjects\Splitter2\app\build\intermediates\explosion-aar\com.android.support\appcompat-v7\22.0.0\res\drawable-hdpi- V4\abc_spinner_mtrl_am_alpha.9.png:

libpng警告:iCCP:无法识别已编辑的已知sRGB配置文件

我的项目终于正在运行,但每次我进行干净的构建时,它都会再次显示此警告.

我将buildToolsVersion更新为"22.0.1",我使用的是tools.build:gradle"1.2.3".我仍然收到这个错误.

当我尝试使用FancyButton时,一切都开始了.

有人知道如何解决这个问题吗?

android

36
推荐指数
4
解决办法
5万
查看次数

您如何组织Dagger 2模块和组件?

你有一个特定的包,你把所有与Dagger相关的课程放在哪里?

或者你把它们放在他们注入的相关课程旁边,例如,如果你有一个MainActivityModuleMainActivityComponent,你把它们放在与你相同的包装中MainActivity.

此外,我见过很多人将组件定义为内部类,例如ApplicationComponent,在Application类中定义的组件.你认为这是一个好习惯吗?

java android dagger-2

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

Android设置Volley使用缓存

我正在尝试为服务器JSON响应创建和使用缓存.

例如:

将JSON对象缓存到内部存储器,并在我们没有Internet连接时使用它.

在下面的示例代码中,我找不到任何有关如何缓存它的文档,Volley并且当再次更新的服务器头不会过期时重用该文档.

像这样:将expiration设置为header并使用缓存并尝试在到期后再次加载.

我正在尝试为此方法设置缓存机制:

private void makeJsonArryReq() {
    JsonArrayRequest req = new JsonArrayRequest(Const.URL_JSON_ARRAY,
            new Response.Listener<JSONArray>() {
                @Override
                public void onResponse(JSONArray response) {
                    msgResponse.setText(response.toString());
                }
            }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
        }
    });
    AppController.getInstance().addToRequestQueue(req,tag_json_arry);
}
Run Code Online (Sandbox Code Playgroud)

缓存方法:

public static Cache.Entry parseIgnoreCacheHeaders(NetworkResponse response) {
    long now = System.currentTimeMillis();

    Map<String, String> headers = response.headers;
    long serverDate = 0;
    String serverEtag = null;
    String headerValue;

    headerValue = headers.get("Date");
    if (headerValue != null) {
        serverDate = HttpHeaderParser.parseDateAsEpoch(headerValue); …
Run Code Online (Sandbox Code Playgroud)

android caching android-volley

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

DataBindingUtil.setContentView - 类型参数T具有不兼容的上限

"Android Studio"显示错误消息"类型参数T具有不兼容的上限:ViewDataBinding和ActivityChecklistsBinding.

ActivityChecklistsBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_checklists);
Run Code Online (Sandbox Code Playgroud)

在更新ADK之前,它工作正常.有什么想法有什么不对吗?

android

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

Android测试原始资源

我在Android Studio中有以下文件夹结构:

??? androidTest
?   ??? java
?   ??? res
?       ??? raw
?           ??? test_file
??? main
    ??? java
    ??? res
        ??? raw
            ??? app_file
Run Code Online (Sandbox Code Playgroud)

我正在尝试访问test_fileandroidTest元素的原始文件夹中存在的资源.这是继承自以下内容的Robotium测试用例中的代码ActivityInstrumentationTestCase2:

InputStream is = this.getInstrumentation()
                 .getContext()
                 .getResources()
                 .openRawResource(R.raw.test_file);
Run Code Online (Sandbox Code Playgroud)

由于无法找到资源,Android Studio会引发参考错误.确切的错误是"无法解析符号test_file".

如何从androidTest资源包中存在的测试用例中引用此资源?

android robotium android-resources

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

如何使用Percentage for android layout?

我们如何使用android视图元素的百分比值?这样的事情

<TextView
        android:id="@+id/"
        android:layout_width="75%"
        android:layout_height="50%"/>
Run Code Online (Sandbox Code Playgroud)

android android-preferences android-view android-styles

36
推荐指数
5
解决办法
4万
查看次数

如何设置react-native android的启动画面

如何设置反应原生android的启动画面,我找不到任何关于该主题的内容,我认为这很奇怪.

谢谢

android react-native

36
推荐指数
3
解决办法
5万
查看次数