国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

您的位置:首頁技術文章
文章詳情頁

android - 安卓activity無法填充屏幕

瀏覽:111日期:2024-08-21 10:12:58

問題描述

新手在開發(fā)安卓的過程中遇到了一些問題,在activity的四周總有去不掉的白邊 ,activity是沒有填滿屏幕的,xml里的設置是macthparent沒錯,不知道問題出在哪里,android - 安卓activity無法填充屏幕

補充一下這個界面的xml代碼

<?xml version='1.0' encoding='utf-8'?><AbsoluteLayout xmlns:android='http://schemas.android.com/apk/res/android'

xmlns:tools='http://schemas.android.com/tools'android:id='@+id/activity_log_in'android:layout_width='match_parent'android:fillViewport='true'android:layout_height='match_parent'android:paddingBottom='@dimen/activity_vertical_margin'android:paddingLeft='@dimen/activity_horizontal_margin'android:paddingRight='@dimen/activity_horizontal_margin'android:background='#ffffff'android:paddingTop='@dimen/activity_vertical_margin'tools:context='com.example.administrator.productiontoolforpda.Activity_logIn'>=<ImageButton android:layout_width='wrap_content' android:layout_height='wrap_content' android:background='@mipmap/login'/>

<LinearLayout

android:layout_width='match_parent'android:layout_height='wrap_content'android:gravity='center'android:layout_x='0dp'android:layout_y='240dp'><EditText android:layout_width='200dp' android:layout_height='35dp' android:autoLink='all' android:hint='用戶名' android:inputType='textPersonName' android:ems='10' android:layout_x='90dp' android:layout_y='112dp' android: android:textSize='14sp' android:text='' />

</LinearLayout>

<LinearLayout android:layout_width='match_parent' android:layout_height='wrap_content' android:gravity='center' android:layout_x='0dp' android:layout_y='290dp'> <EditTextandroid:layout_width='200dp'android:layout_height='35dp'android:inputType='textPassword'android:ems='10'android:hint='密碼'android:layout_x='90dp'android:layout_y='152dp'android: android:text=''android:textSize='14sp' /></LinearLayout><LinearLayout android:layout_width='match_parent' android:layout_height='wrap_content' android:layout_x='0dp' android:layout_y='340dp' android:orientation='vertical' > <Buttonandroid:text='確認'android:background='@drawable/textview_round_border_blue'android:textColor='#ffffff'android:layout_width='match_parent'android:layout_height='50dp'android:layout_x='25dp'android:layout_y='220dp'android: android:layout_weight='1' /> <Buttonandroid:text='取消'android:background='@drawable/textview_round_border_blue'android:layout_width='match_parent'android:textColor='#ffffff'android:layout_height='50dp'android:layout_x='175dp'android:layout_y='220dp'android: android:layout_weight='1' /></LinearLayout>

</AbsoluteLayout>

java代碼

package com.example.administrator.productiontoolforpda;

import android.app.Activity;import android.app.Dialog;import android.content.ContentValues;import android.content.Context;import android.content.Intent;import android.database.Cursor;import android.graphics.Color;import android.os.Handler;import android.os.Message;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.telephony.TelephonyManager;import android.util.Log;import android.view.Gravity;import android.view.LayoutInflater;import android.view.View;import android.view.Window;import android.view.WindowManager;import android.widget.Button;import android.widget.EditText;import android.widget.TextView;import android.widget.Toast;

import org.w3c.dom.Text;

import java.sql.Date;import java.text.SimpleDateFormat;

import static com.example.administrator.productiontoolforpda.myApplication.getContext;

public class Activity_logIn extends Dialog {

private EditText account;private HttpInfo httpInfo;private EditText password;private Button ok;private Button cancel;private DBHelper dbHelper ;public static String VERSION = 'v1.0';public String DEVICE_ID;public Activity_logIn(Context context){ super(context,R.style.PopupDialog);

// }

//protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); Window win = this.getWindow(); win.setGravity(Gravity.BOTTOM); //從下方彈出 win.getDecorView().setPadding(0, 0, 0, 0); WindowManager.LayoutParams lp = win.getAttributes(); lp.width = WindowManager.LayoutParams.MATCH_PARENT; //寬度填滿 lp.height = WindowManager.LayoutParams.WRAP_CONTENT; //高度自適應 win.setAttributes(lp); super.setContentView(R.layout.activity_log_in); account = (EditText)findViewById(R.id.account); password = (EditText)findViewById(R.id.password); ok = (Button)findViewById(R.id.ok); cancel = (Button)findViewById(R.id.cancel); TelephonyManager tm = (TelephonyManager)myApplication.getContext().getSystemService(Context.TELEPHONY_SERVICE); DEVICE_ID = tm.getDeviceId(); httpInfo = new HttpInfo(); dbHelper = new DBHelper(myApplication.getContext()); //填充登陸賬號和密碼 InputUserInfo(); ok.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) { String username = account.getText().toString(); String p = password.getText().toString(); ContentValues values = new ContentValues(); //new newThread().start(); //申請產線列表 httpInfo.lineTest(); values.put('username',username); values.put('password',p); dbHelper.deleteFormUser(); dbHelper.insertIntoUser(values); //寫入產線信息 Activity_logIn.this.dismiss();} }); cancel.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) { Activity_logIn.this.dismiss();} });}//測試滾動barpublic void insertLineInfo(){ for(int i = 0;i<5;i++){ContentValues values2 = new ContentValues();values2.put('lineNum','未設置產線'+i);dbHelper.insertIntoLineNum(values2); }}public void InputUserInfo(){ Cursor c = dbHelper.queryFromUser(); if(c.moveToFirst()) {account.setText(c.getString(1));password.setText(c.getString(2)); }}class newThread extends Thread{ public void run(){String username = account.getText().toString();String pw = password.getText().toString();Message msg = new Message();try { httpInfo.getInfoFromWeb(username, pw, DEVICE_ID);}catch (Exception e) { Log.e('eeeeeeeee',e.toString());}if(httpInfo.status=='0'){ httpInfo.updataLineNum(); msg.what = 0; mHandler.sendMessage(msg); Intent i = new Intent(myApplication.getContext(),Activity_setLineNum.class); myApplication.getContext().startActivity(i); Activity_logIn.this.dismiss();}else { msg.what = 1; mHandler.sendMessage(msg);} }}private Handler mHandler = new Handler(){ @Override public void handleMessage(Message msg) {super.handleMessage(msg);switch (msg.what) { case 0:Toast.makeText(getContext(), '登陸成功', Toast.LENGTH_SHORT).show();break; case 1:Toast.makeText(getContext(), httpInfo.message, Toast.LENGTH_SHORT).show();break;} }};

}

問題解答

回答1:

第一個xml文件里面

android:paddingBottom='@dimen/activity_vertical_margin'android:paddingLeft='@dimen/activity_horizontal_margin'android:paddingRight='@dimen/activity_horizontal_margin'android:paddingTop='@dimen/activity_vertical_margin'

這里有設置了padding,刪除這些即可

回答2:

貼布局代碼上來,要學會問問題,這樣問誰也無法確切知道你的問題在哪,我只能估計你的布局xml保留了自動生成時的padding值,把這個去掉。

回答3:

樓上正解,估計不是margin就是padding

相關文章:
主站蜘蛛池模板: 精品一区二区高清在线观看 | 在线观看精品国内福利视频 | 中文字幕一二区 | 国内自拍第1页 | 国产日韩在线视频 | 成人高清视频免费观看 | 日韩激情无码免费毛片 | 在线国产一区 | 精品视频国产狼人视频 | 国产原创在线视频 | 国产精品久久久久久久久久久搜索 | 刺激一区仑乱 | 色久激情| 久久夜色精品国产噜噜亚洲a | 国产一级毛片一区二区三区 | 伊人久久91 | 国产成人黄网址在线视频 | 一区二区三区在线免费观看视频 | 成人免费a视频 | 欧美一区二区三区视视频 | 91久久国产综合精品 | 天天躁天天碰天天看 | 毛片a级三毛片免费播放 | 日韩欧一级毛片在线播无遮挡 | 国产一区二区不卡 | 国产粗大猛烈18p | 日韩欧美特级毛片 | 日本乱人伦片中文字幕三区 | 天堂亚洲网| 国产九九视频在线观看 | 日本久久草 | 国产精品天堂avav在线 | 91在线成人 | 自拍理论片 | 国产制服 国产制服一区二区 | 怡红院在线视频全部观看 | 国产精品视频免费一区二区三区 | 国产日产欧美精品一区二区三区 | 国产精品久久久久一区二区三区 | 久久久免费视频播放 | 国产日韩在线观看视频 |