⑴ android的在同一個layout如何豎排實現輸出
LinearLayout 中設置 android:orientation="vertical" 這樣就是豎直排列 LinearLayout 中的所有子布局都是豎直的 你把 A 圖片 B 依次寫在LinearLayout 中就行了
⑵ android 自定義viewgroup 怎麼讓子view豎著排
添加的子View,如果用hierarchyviewer工具可以看到,而你看不到,那麼可能原因有:
1、是你添加子View的時候裡面已經有View了,並被蓋住了。可以先調用removeAllViews()試下。
2、oncreate能看到,onresume不能看到,調用setContentView()方法試下,應該是沒有刷新當前界面
⑶ Android給圖片添加豎排文字水印
就下載一個加水印的軟體就可以了。
文字水印代碼:
privateBitmapcreateBitmap(Bitmapphoto,Stringstr,intmark_x,intmark_y){
intwidth=photo.getWidth(),hight=photo.getHeight();
System.out.println("寬"width"高"hight);
//建立一個空的BItMap
Bitmapicon=Bitmap.createBitmap(width,hight,Bitmap.Config.ARGB_8888);
//初始化畫布繪制的圖像到icon上
Canvascanvas=newCanvas(icon);
PaintphotoPaint=newPaint();//建立畫筆
photoPaint.setDither(true);//獲取跟清晰的圖像采樣
photoPaint.setFilterBitmap(true);//過濾一些
//創建一個指定的新矩形的坐標
Rectsrc=newRect(0,0,photo.getWidth(),photo.getHeight());
//創建一個指定的新矩形的坐標
Rectdst=newRect(0,0,width,hight);
//將photo縮放或則擴大到dst使用的填充區photoPaint
canvas.drawBitmap(photo,src,dst,photoPaint);
⑷ Android:多張豎著的圖片(一屏幕放不下)用什麼實現
網路載入還是你直接寫,1.不行就寫個listview,2.非得放在一個屏幕里就linearlayout里邊加權重weight=「1」,就可以了但是圖片可能都是小小的。
方法一 就是item點擊事件,然後switch(pos)case 0-5。方法二就是每一個都加id做點擊事件。
還有一個辦法,非要豎向單排么,可以豎向雙排,或者豎向3排么,recycleview了解一下。 item事件需要自己寫。
⑸ Android 如何實現豎排文字顯示
在android.graphics.Canvas類中有個沿路徑畫字的方法
void drawTextOnPath(String text, Path path, float hOffset, float vOffset, Paint paint)
Draw the text, with origin at (x,y), using the specified paint, along the specified path.
void drawTextOnPath(char[] text, int index, int count, Path path, float hOffset, float vOffset, Paint paint)
Draw the text, with origin at (x,y), using the specified paint, along the specified path.
Test.java代碼://需要在layout中定義Test,且設置背景,在java代碼中設置test Text
public class Test extends View {
private Paint paint;
private Path path;
private Matrix matrix;
private int width = -1;
private int height = -1;
private float left = 3;
private float top = 18;
private String title = "";
BitmapDrawable drawable = (BitmapDrawable) getBackground();
public Test(Context context, AttributeSet attrs) {
super(context, attrs);
paint = new Paint();
paint.setColor(Color.WHITE);//定義字體顏色
paint.setTextSize(14);//定義字體大小
path = new Path();
path.lineTo(0,500);//定義字元路徑
matrix = new Matrix();
Log.v("onMeasure", "2");
}
@Override
protected void onDraw(Canvas canvas) {
//畫背景
Bitmap b = Bitmap.createBitmap(drawable.getBitmap(),0,0,width,height);
canvas.drawBitmap(b, matrix, paint);
//畫字
showText(canvas, title);
}
private void showText(Canvas canvas, String text){
float w;
final int len = text.length();
float py = 0 + top;
for(int i=0; i<len; i ++){
char c = text.charAt(i);
w = paint.measureText(text, i, i+1);//獲取字元寬度
StringBuffer b = new StringBuffer();
b.append(c);
if(py > 81){//定義字的范圍
return;
}
if(isChinese(c)){
py += w;
if(py > 81){
return;
}
canvas.drawText(b.toString(), left, py, paint); //中文處理方法
}else {
canvas.drawTextOnPath(b.toString(), path, py, -left-2, paint);//其他文字處理方法
py += w;
}
}
}
public void setText(String title){
this.title = title;
}
public String getText(){
return title;
}
private boolean isChinese(char c) {
Character.UnicodeBlock ub = Character.UnicodeBlock.of(c);
if (ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS
|| ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS
|| ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A
|| ub == Character.UnicodeBlock.GENERAL_PUNCTUATION
|| ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION
|| ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS) {
return true;
}
return false;
}
//重寫View大小方法,使view大小為背景圖片大小
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// super.onMeasure(widthMeasureSpec, heightMeasureSpec);
if (null != getBackground()) {
int h = drawable.getIntrinsicHeight();
int w = drawable.getIntrinsicWidth();
Log.v("onMeasure", "null != getBackground() h:" + h + " w:" + w);
width = w;
height = h;
setMeasuredDimension(w, h);
} else {
width = widthMeasureSpec;
height = heightMeasureSpec;
super.measure(widthMeasureSpec, heightMeasureSpec);
}
}
}
在Android中,若要通過程序改變屏幕顯示的方向,必須要覆蓋setRequestedOrientation()方法,而若要取得目前的屏幕方向,則需要訪問getRequestedOrientation()方法。本範例為求簡要示範更改做法,設計了一個按鈕,當單擊按鈕的同時,判斷當下的屏幕方向,例如豎排(PORTRAIT),則將其更改為橫排(LANDSCAPE);若為橫排(LANDSCAPE),則將其更改為豎排(PORTRAIT)
⑹ 怎麼讓textview中的文字豎著顯示
public class RotateTextView extends TextView {
private static final String NAMESPACE = "
private static final String ATTR_ROTATE = "rotate";
private static final int DEFAULTVALUE_DEGREES = 0;
private int degrees ;
public RotateTextView(Context context){
super(context);
}
public RotateTextView(Context context, AttributeSet attrs) {
super(context, attrs);
degrees = attrs.getAttributeIntValue(NAMESPACE, ATTR_ROTATE, DEFAULTVALUE_DEGREES);
}
public RotateTextView(Context context, AttributeSet attrs,int defStyle) {
super(context, attrs,defStyle);
}
@Override
protected void onDraw(Canvas canvas) {
canvas.rotate(degrees,getMeasuredWidth()/2,getMeasuredHeight()/2);
super.onDraw(canvas);
}
}
<com.test.RotateTextView xmlns:myrotate="
android:layout_height="wrap_content"
android:layout_marginTop="468dip"
android:padding="60dip"
android:linksClickable="true"
android:autoLink="web"
android:gravity="center"
android:id="@+id/test"
myrotate:rotate="-45"
android:textSize="20dip"
android:text="7\n\n16"/>
⑺ 如何讓textview中的文字豎著顯示
public class RotateTextView extends TextView {
private static final String NAMESPACE = "
private static final String ATTR_ROTATE = "rotate";
private static final int DEFAULTVALUE_DEGREES = 0;
private int degrees ;
public RotateTextView(Context context){
super(context);
}
public RotateTextView(Context context, AttributeSet attrs) {
super(context, attrs);
degrees = attrs.getAttributeIntValue(NAMESPACE, ATTR_ROTATE, DEFAULTVALUE_DEGREES);
}
public RotateTextView(Context context, AttributeSet attrs,int defStyle) {
super(context, attrs,defStyle);
}
@Override
protected void onDraw(Canvas canvas) {
canvas.rotate(degrees,getMeasuredWidth()/2,getMeasuredHeight()/2);
super.onDraw(canvas);
}
}
<com.test.RotateTextView xmlns:myrotate="http://myrotate.com/apk/res/myrotate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="468dip"
android:padding="60dip"
android:linksClickable="true"
android:autoLink="web"
android:gravity="center"
android:id="@+id/test"
myrotate:rotate="-45"
android:textSize="20dip"
android:text="7\n\n16"/>
⑻ Android 如何實現豎排文字顯示
package com.coolsoft.attributionreject.tools;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.LinearLayout;
import android.widget.TextView;
public class VerticalTextView extends LinearLayout{
public VerticalTextView(Context context, AttributeSet attrs) {
super(context, attrs);
setOrientation(VERTICAL);
this.context=context;
}
private String text;
private Context context;
private int color;
private int size=15;
public VerticalTextView(Context context) {
super(context);
setOrientation(VERTICAL);
this.context=context;
}
public void setText(String text)
{
this.text=text;
addText();
}
private void addText()
{
removeAllViews();
if(text!=null)
{
char[] chara=text.toCharArray();
for(int i=0;i<chara.length;i++)
{
System.out.println("什麼情況------"+text);
TextView oneText=new TextView(context);
oneText.setTextColor(color);
oneText.setText(text.substring(i, i+1));
if(size>0)
{
oneText.setTextSize(size);
}
addView(oneText);
}
}
}
public void setTextColor(int color)
{
this.color=color;
}
public void setTextSize(int size)
{
this.size=size;
}
}
你也可以修改里邊的字體大小的。最好字數不要多,這樣的空間字數多了消耗比較的大。
在xml當中加入包名,這個應該知道吧。
⑼ 安卓手機怎麼設置豎排方向鎖定
在待機界面,從屏幕頂端往下拉,會看到一些常用菜單。找到屏幕鎖定那個功能,橫屏時候按鎖定就是橫屏,豎屏時候按鎖定就是豎屏。不按鎖定的話手機會根據使用方向自動切換橫屏或者豎屏。