小编GOL*_*DEE的帖子

修复了ViewPager内容布局中CoordinatorLayout下的视图

我的应用程序有一个ActivityTabLayout,和3 Fragments.在Activity's布局,我都CoordinatorLayoutViewPager.我也需要动画工具栏.现在在Fragments布局中,我需要在底部放置一个固定的TextView.下面给出的是XML活动和片段.

我面临的问题是,TextView在Fragment的布局中修复的问题是在底部导航栏下面并且也在滚动,我不想要.

怎么能实现这个?

activity.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/clMain"
    android:layout_width="match_parent"
    android:layout_height="match_parent">


    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways|snap"
            app:popupTheme="@style/AppTheme.PopupOverlay">

            <TextView
                android:id="@+id/toolbar_title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/app_name"
                android:textColor="#FFFFFF"
                android:textSize="22sp"
                android:textStyle="bold" />
        </android.support.v7.widget.Toolbar>

        <android.support.design.widget.TabLayout
            android:id="@+id/tab_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/toolbar"
            android:background="?attr/colorPrimary"
            android:minHeight="?attr/actionBarSize"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />

    </android.support.design.widget.AppBarLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

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

fragment.xml之

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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" …
Run Code Online (Sandbox Code Playgroud)

android android-viewpager material-design android-coordinatorlayout android-appbarlayout

4
推荐指数
1
解决办法
3832
查看次数

如何在Android上强制关闭系统关闭应用程序

我想强制关闭我的应用程序作为Android系统.
如选择下面的系统步骤.

"Setting" -> "Apps" -> "my app name" -> "Force stop"  
Run Code Online (Sandbox Code Playgroud)

我想通过代码实现相同的行为.
我该怎么做?

android forceclose

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

将2个值从一个活动传递给另一个活动

我对android很新.即时尝试开发练习的登录表单,我无法传递和显示2个值到另一个活动

Intent intent = new Intent(this, Success.class);
        EditText edituser = (EditText) findViewById(R.id.userinput);
        EditText editpass= (EditText) findViewById(R.id.passinput);
        String username = edituser.getText().toString();
        String password = editpass.getText().toString();

        intent.putExtra(EXTRA_USER, username);
        intent.putExtra(EXTRA_PASSWORD, password);
        startActivity(intent);
Run Code Online (Sandbox Code Playgroud)

和目标活动是

 Intent intent = getIntent();
    String username = intent.getStringExtra(MainActivity.EXTRA_USER);
    String password = intent.getStringExtra(MainActivity.EXTRA_PASSWORD);

    // Create the text view
    TextView userView = new TextView(this);
    TextView passView = new TextView(this);
    userView.setTextSize(40);
    userView.setText(username);

    passView.setTextSize(40);
    passView.setText(password);

    // Set the text view as the activity layout
    setContentView(userView);
    setContentView(passView);
Run Code Online (Sandbox Code Playgroud)

java android android-intent

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

无法在Android JellyBean上构建hello world内核模块

我正在尝试在Android JellyBean上构建一个简单的内核模块.

码:

#include <linux/module.h>  /* Needed by all modules */
#include <linux/kernel.h>  /* Needed for KERN_ALERT */

MODULE_LICENSE("GPL");
MODULE_AUTHOR("test");
MODULE_DESCRIPTION("Android ko test");

int init_module(void)
{
   printk(KERN_ALERT, "Hello world\n");

   // A non 0 return means init_module failed; module can't be loaded.
   return 0;
}

void cleanup_module(void)
{
  printk(KERN_ALERT "Goodbye world 1.\n");
}
Run Code Online (Sandbox Code Playgroud)

Makefile文件:

obj-m +=hello.o

KERNELDIR ?= ~/android/kernel
PWD := $(shell pwd)
CROSS_COMPILE=~/android/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-
ARCH=arm

default:
    $(MAKE) -C $(KERNELDIR) M=$(PWD) ARCH=arm CROSS_COMPILE=$(CROSS_COMPILE) modules

clean:
    $(MAKE) -C $(KERNELDIR) M=$(PWD) clean
Run Code Online (Sandbox Code Playgroud)

输出:

make …
Run Code Online (Sandbox Code Playgroud)

linux android android-4.2-jelly-bean

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