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

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

android - 安卓activity無法填充屏幕

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

問題描述

新手在開發安卓的過程中遇到了一些問題,在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

相關文章:
主站蜘蛛池模板: 一级片a | 成人午夜大片免费7777 | 国产成人亚洲综合欧美一部 | 日本欧美韩国一区二区三区 | 亚洲jjzzjjzz在线播放 | 久久精品视频16 | 国产午夜在线观看视频播放 | 亚洲国产美女视频 | 欧美日韩在线看 | 日本高清视频www夜色资源 | 99免费在线播放99久久免费 | 精品一区二区三区在线播放 | a国产成人免费视频 | 一级做a爰性色毛片免费 | 亚洲在线中文 | 国产激情一区二区三区四区 | 国产综合成人久久大片91 | 污全彩肉肉无遮挡彩色 | 国产aⅴ精品一区二区三区久久 | 精品欧美高清不卡在线 | 黄色美女视频免费看 | 日本高清视频免费在线观看 | 欧美一区二区三区激情视频 | 亚洲视频毛片 | 美女成人网 | 中文字幕日本一区波多野不卡 | 男女视频在线观看免费 | 国产三级三级三级 | 欧美一区二区三区视频在线观看 | 加勒比日本道 | 久久综合日韩亚洲精品色 | 黄色一级片a | 亚洲欧洲日产国码二区首页 | 9久9久热精品视频在线观看 | 亚洲成aⅴ人片在线观 | 日本特一级毛片免费视频 | 精品国产一区二区 | 欧美三级做爰视频 | 成年人在线免费网站 | 色资源二区在线视频 | 免费人成激情视频在线观看冫 |