fitsystemwindowlayout配置和界面实现

首先检查gradle配置文件,我的

gradle-wrapper.properties

#Mon Dec 28 10:00:20 PST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip

还需修改文件的gradle(project):

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

修改文件的gradle(mudule:app):

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.0"
    defaultConfig {
        applicationId "com.lnz.uitest02"
        minSdkVersion 14
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.0.0'
    testCompile 'junit:junit:4.12'
}

之后就可以导入库文件了.

File->New->Input Module...->导入fitsystemwindowlayout库文件;如下:

copy代码

mainAcitivity.java

package com.lnz.uitest02;

import android.os.Bundle;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.jude.fitsystemwindowlayout.Utils;


public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        //ImageView pagerView = (ImageView) findViewById(R.id.viewpager);

        Utils.paddingToNavigationBar(findViewById(R.id.content));
    }

//    private class TestLoopAdapter extends LoopPagerAdapter {
//        private int[] imgs = {
//                R.drawable.img0
//        };
//
//        public TestLoopAdapter(RollPagerView viewPager) {
//            super(viewPager);
//        }
//
//        @Override
//        public View getView(ViewGroup container, int position) {
//            ImageView view = new ImageView(container.getContext());
//            view.setImageResource(imgs[position]);
//            view.setScaleType(ImageView.ScaleType.CENTER_CROP);
//            view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
//            return view;
//        }
//
//        @Override
//        public int getRealCount() {
//            return imgs.length;
//        }
//
//    }

//    @Override
//    public void onBackPressed() {
//        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
//        if (drawer.isDrawerOpen(GravityCompat.START)) {
//            drawer.closeDrawer(GravityCompat.START);
//        } else {
//            super.onBackPressed();
//        }
//    }
//}

activity_main.xml

(这里记录一下,ScrollView只能有一个子元素,解决办法就是把多个子元素包含在一个LinearLayout或者RelativeLayout中.)

<?xml version="1.0" encoding="utf-8"?>
<com.jude.fitsystemwindowlayout.FitSystemWindowsFrameLayout
    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:layout_width="match_parent"
    android:layout_height="match_parent"
    app:padding_status="false"
    >

    <ImageView
        android:id="@+id/photo"
        android:layout_width="match_parent"
        android:layout_height="300dp"
        android:src="@drawable/img0"
        android:scaleType="fitXY"
        />

    <ScrollView
        android:id="@+id/content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:padding_navigation="true"
        android:layout_marginTop="300dp">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            style="@style/Base.TextAppearance.AppCompat.Display3"
            android:text="A\nB\nC\nD\nE\nF\nG"/>
    </ScrollView>

</com.jude.fitsystemwindowlayout.FitSystemWindowsFrameLayout>




添加图片到res/drawable/img0.png


重点在styles.xml上

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/blue</item>
        <item name="colorPrimaryDark">@color/blue900</item>
        <item name="colorAccent">@color/pink</item>
        <item name="android:windowIsTranslucent">true</item>
    </style>


    <style name="AppTheme" parent="AppTheme.Base"></style>

    <style name="AppTheme.Dark" parent="Theme.AppCompat.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorAccent">@color/orange</item>
        <item name="colorPrimary">@color/blue</item>
        <item name="colorPrimaryDark">@color/blue</item>
        <item name="drawerArrowStyle">@style/MaterialDrawer.DrawerArrowStyle</item>
    </style>
    <style name="MaterialDrawer.DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
        <item name="spinBars">false</item>
        <item name="color">@android:color/white</item>
    </style>
</resources>
创建res/values-v19/styles.xml

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/blue</item>
        <item name="colorPrimaryDark">@color/blue900</item>
        <item name="colorAccent">@color/pink</item>
        <item name="android:windowIsTranslucent">true</item>
    </style>


    <style name="AppTheme" parent="AppTheme.Base"></style>

    <style name="AppTheme.Dark" parent="Theme.AppCompat.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorAccent">@color/orange</item>
        <item name="colorPrimary">@color/blue</item>
        <item name="colorPrimaryDark">@color/blue</item>
        <item name="drawerArrowStyle">@style/MaterialDrawer.DrawerArrowStyle</item>
    </style>
    <style name="MaterialDrawer.DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
        <item name="spinBars">false</item>
        <item name="color">@android:color/white</item>
    </style>
</resources>


创建res/values-v21/styles.xml

<resources>

    <style name="AppTheme" parent="AppTheme.Base">
        <item name="android:windowTranslucentStatus">true</item>
        <item name="android:windowTranslucentNavigation">true</item>
        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    </style>
</resources>

添加color.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="colorPrimary">#3F51B5</color>
    <color name="colorPrimaryDark">#303F9F</color>
    <color name="colorAccent">#FF4081</color>

    <color name="orange">#ff5722</color>
    <color name="blue">#2196F3</color>
    <color name="blue900">#0D47A1</color>
    <color name="pink">#E91E63</color>
    <color name="white">#fff</color>
    <color name="purple">#9C27B0</color>
    <color name="indigo">#3F51B5</color>
    <color name="cyan">#00BCD4</color>
    <color name="teal">#009688</color>
    <color name="gray">#888888</color>
    <color name="gray100">#dddddd</color>
    <color name="gray600">#999999</color>
</resources>

初步完成.效果如下:

代码有空上传.


程序设计题二:ZIP格式压缩/解压系统设计 【问题描述】 由于网络带宽的限制,开发以互联网为传输媒介的软件系统时,在运行过程中的数据传输效率会成为评价一套软件系统性能的重要指标。由于网络的数据传输速度是软件运行的客观因素,因此,在这种情况下,程序设计人员首先考虑的减少软件系统运行过程中需要传输的数据量,如果有些数据必须要传输,则软件工程师通常将这些数据在发送端进行压缩,而在数据接收端将数据解压缩,从而主动减少应用系统数据传输量。 JDK环境中提供了多种类型的数据压缩方式,总结起来,利用Java语言可以创建的数据文件压缩格式包括如下类型:   ●ZIP格式   ●GZIP格式   ●JAR格式 通过设计,允许创建ZIP压缩文件,并对ZIP压缩文件中包含的文件进行显示、添加、解压、删除等操作。GUI界面与下图类似: 【实验目的】 要求学生能熟练使用基于Swing的GUI设计,熟练使用常用组件和容器,理解java事件处理机制,会查看API documentation完成设计任务,熟练文件流的操作。 【基本功能】 (1) 通过菜单组件、按钮组件、文本框组件等完成创建ZIP压缩文件。 (2) ZIP压缩文件中包含的文件进行显示、添加、解压、删除等操作 (3) 功能的其他扩展 【指导建议】 完成实验指导书P97“Zip文件的读取与制作” 将程序进行修改,增加GUI设计,并完成基本功能, 其他功能扩展和完善。 【程序设计的开发环境】 JDK1.5 及JCreator350/400。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值