我创建了以下xml布局,但它没有显示EditText Name&电子邮件格式正确。我该如何解决这个问题?
这里我使用了权重和3和布局权重1
答案 0 :(得分:0)
首先分享您的 XML
使用layout_weight参数的LinearLayout尤其如此 因为每个孩子需要测量两次,所以费用很高。
<强>机器人:weightSum 强>
定义最大重量总和。如果未指定,则总和通过计算 添加所有子项的layout_weight。这可以用于 实例给予单个孩子50%的总可用空间 给它一个layout_weight为0.5并将weightSum设置为1.0。
您可以查看 Android LinearLayout example
在android线性布局中,怀特婴儿车放置了一些主要角色 不同的支持决议。我的意思是通过使用wightsum android中的线性布局会将其扩展到整个屏幕。
引自 Weight/Weight sum in android
实施例
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="msapplication-tap-highlight" content="no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<title>Camera Demo</title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script src="js/jquery-1.11.3.min.js"></script>
<script type="text/javascript">
var pictureSource; // picture source
var destinationType; // sets the format of returned value
// Wait for Cordova to load
document.addEventListener('deviceready', onDeviceReady, false);
// Cordova is ready
function onDeviceReady() {
pictureSource=navigator.camera.PictureSourceType;
destinationType=navigator.camera.DestinationType;
}
// Called when a photo is successfully retrieved
function onPhotoDataSuccess(imageData) {
// Uncomment to view the base64-encoded image data
console.log(" "+imageData);
// Get image handle
//
var smallImage = document.getElementById('smallImage');
// Unhide image elements
//
smallImage.style.display = 'block';
// Show the captured photo
// The inline CSS rules are used to resize the image
//
smallImage.src = "data:image/jpeg;base64," + imageData;
}
// Called when a photo is successfully retrieved
//
function onPhotoURISuccess(imageURI) {
// Uncomment to view the image file URI
// console.log("IMAGE PATH: "+imageURI);
alert("Image Url : "+imageURI);
// Get image handle
//
var largeImage = document.getElementById('largeImage');
// Unhide image elements
//
largeImage.style.display = 'block';
// Show the captured photo
// The inline CSS rules are used to resize the image
//
largeImage.src = imageURI;
}
// A button will call this function
//
function capturePhoto() {
// Take picture using device camera and retrieve image as base64-encoded string
navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50,
destinationType: destinationType.DATA_URL });
}
// A button will call this function
//
function capturePhotoEdit() {
// Take picture using device camera, allow edit, and retrieve image as base64-encoded string
navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 20, allowEdit: true,
destinationType: destinationType.DATA_URL });
}
// A button will call this function
//
function getPhoto(source) {
// Retrieve image file location from specified source
navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 50,
destinationType: destinationType.FILE_URI,
sourceType: source });
}
// Called if something bad happens.
//
function onFail(message) {
alert('Failed because: ' + message);
}
</script>
</head>
<body>
<header class="header">
<div class="header-div">
<div class="header-single">
<span id="title">Details </span>
</div>
</div>
</header>
<div class="clear">
</div>
<content class="content-style">
<h2> Camera Demo</h2>
<button class="demo-btn-style" onclick="capturePhoto();">Capture Photo</button> <br>
<button class="demo-btn-style" onclick="capturePhotoEdit();">Capture Editable Photo</button> <br>
<button class="demo-btn-style" onclick="getPhoto(pictureSource.PHOTOLIBRARY);">From Photo Library</button><br>
<button class="demo-btn-style" onclick="getPhoto(pictureSource.SAVEDPHOTOALBUM);">From Photo Album</button><br>
Small image: <br>
<img style="display:none;width:100px;height:100px;" id="smallImage" src="" /> <br>
Large image: <br>
<img style="display:none;" id="largeImage" src="" /> <br>
</content>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
</boyd>
</html>