zoukankan      html  css  js  c++  java
  • android小技巧

    1.锁定 Activity 运行时的屏幕方向

      Android 内置了方向感应器的支持。在 G1 中,Android 会根据 G1 所处的方向自动在竖屏和横屏间切换。但是有时我们的应用程序仅能在横屏 / 竖屏时运行,比如某些游戏,此时我们需要锁定该 Activity 运行时的屏幕方向,<activity >节点的 android:screenOrientation属性可以完成该项任务,示例代码如下:

         <activity android:name=".EX01"  
          android:label="@string/app_name"   
          android:screenOrientation="portrait">// 竖屏 , 值为 landscape 时为横屏  
         …………  
          </activity> 

    2、全屏的 Activity

      要使一个 Activity 全屏运行,可以在其 onCreate()方法中添加如下代码实现:

       // 设置全屏模式     
         getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);   
       // 去除标题栏  
         requestWindowFeature(Window.FEATURE_NO_TITLE); 

    3. 设置对话框弹出位置和大小

           AlertDialog dialog = new AlertDialog.Builder(this).setTitle("信息").setMessage("您好").create();
                dialog.show();
                Window  window = dialog.getWindow();    
                window.setLayout(200, 200); //setLayout一定要放在show()方法之后,不然不起作用
                window.setGravity(Gravity.TOP);

     4.除去ScrollVIew拉到尽头时再拉的阴影效果

      XML文件中添加以下方法: 

     android:fadingEdge=”none”
       或者,代码中设置为false即可
     ScrollView.setHorizontalFadingEdgeEnabled(false);

     5. android内容太多滚动的实现

      在Layout外面包一层ScrollView即可

    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scrollbars="vertical"
        android:fadingEdge="none"
        android:background="@color/main_bg">
     <LinearLayout> </LinearLayout>
    </ScrollView>
  • 相关阅读:
    shell进行mysql统计
    java I/O总结
    Hbase源码分析:Hbase UI中Requests Per Second的具体含义
    ASP.NET Session State Overview
    What is an ISAPI Extension?
    innerxml and outerxml
    postman
    FileZilla文件下载的目录
    how to use webpart container in kentico
    Consider using EXISTS instead of IN
  • 原文地址:https://www.cnblogs.com/xiang1336/p/3730102.html
Copyright © 2011-2022 走看看