国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-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级精美理论片 | 亚洲三级理论 | 亚洲美女高清aⅴ视频免费 亚洲美女黄色片 | 日韩欧美在线播放视频 | 成人黄激情免费视频 | 国产成人精品日本亚洲网址 | 欧美xo影院| 成人18视频在线 | 亚洲精品综合一区二区三区在线 | 中文字幕成人网 | 日本老熟妇激情毛片 | 久草视频精品 | 精品国产成人三级在线观看 | 国产免费专区 | 日本三级香港三级人妇 m | 欧美三级视频在线观看 | 中国一级特黄真人毛片 | 久草视频在线资源 | 久久久国产99久久国产首页 | 午夜国产精品不卡在线观看 | 亚洲精品一区二区三区四区 | 美女与男人对肌免费网站 | 久久国产精品99久久小说 | 久久久久久网站 | 香港aa三级久久三级 | 亚洲天堂毛片 | 国产高清在线精品一区a | 日本高清乱偷www | 尤蜜网站在线进入免费 | 久青草国产手机在线观 | 欧洲亚洲一区 | 91精品视频播放 | 精品自拍视频在线观看 | 成年女人免费看 | 亚洲福利精品一区二区三区 | 俄罗斯一级成人毛片 | 97视频免费播放观看在线视频 | 精品一区二区三区视频 | 精品欧美一区二区在线观看 | 俄罗斯美女在线观看一区 | 2019在线亚洲成年视频网站 |