小编Goo*_*ofy的帖子

捏缩放文本视图

我想为文本视图执行捏合功能(放大/缩小).

我已经参考了很多教程,但没有得到任何有成效的...请帮助我,如果有人做过或知道如何做到....

使用按钮作为放大和/或使用2指针捏还可以吗?

任何帮助将不胜感激..谢谢

不工作的代码:

  setContentView(R.layout.main);
  mainView =(LinearLayout)findViewById(R.id.linearLayout);

  Button buttonZoomOut = (Button)findViewById(R.id.buttonZoomOut);
  Button buttonNormal = (Button)findViewById(R.id.buttonNormal);
  Button buttonZoomIn = (Button)findViewById(R.id.buttonZoomIn);

  buttonZoomOut.setOnClickListener(new View.OnClickListener() {    
   public void onClick(View v) {
    zoom(0.5f,0.5f,new PointF(0,0));    
   }
  });
  buttonNormal.setOnClickListener(new OnClickListener() {

   public void onClick(View v) {
    zoom(1f,1f,new PointF(0,0));  
   }
  });
  buttonZoomIn.setOnClickListener(new View.OnClickListener() {

   public void onClick(View v) {
    zoom(2f,2f,new PointF(0,0));   
   }
  });
 }

 /** zooming is done from here */
 public void zoom(Float scaleX,Float scaleY,PointF pivot){
  mainView.setPivotX(pivot.x);
  mainView.setPivotY(pivot.y);  
  mainView.setScaleX(scaleX);
  mainView.setScaleY(scaleY);  
 } 
Run Code Online (Sandbox Code Playgroud)

android

8
推荐指数
1
解决办法
8488
查看次数

将图像添加到具有形状的layerlist项目

我有一个xml如下我试图从drawable文件夹添加一个图像,但它无法正常工作.

<solid android:color="#FFF"/> 这是我需要从drawable文件夹添加图像的地方

<shape xmlns:android="http://schemas.android.com/apk/res/android">
        <solid android:color="#FFF"/>
        <stroke android:width="1dip" android:color="#225786" />
        <corners android:radius="10dip"/>
        <padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
    </shape>
Run Code Online (Sandbox Code Playgroud)

是否有任何其他方式,我可以添加我尝试使用项目的层列表这是我尝试过的方式

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">  
    <item android:drawable="@drawable/background">
        <shape>
            <solid/>
            <stroke android:width="1dip" android:color="#225786" />
            <corners android:radius="10dip"/>
            <padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
        </shape>
    </item> 
  </layer-list> 
Run Code Online (Sandbox Code Playgroud)

现在它没有显示我正在做的形状边框,它只添加了背景.

android shape layer

8
推荐指数
1
解决办法
2万
查看次数

将Android应用程序与网站上的数据库连接

我需要用户使用登录名和密码注册到我的网站.

基本上我需要做以下事情

1.将android应用程序与网站上的数据库连接.

2.将一些信息存储到数据库中.

3.从数据库中恢复一些信息.

我已经体验过Android应用程序中的标准sqlite构建.问题是,我需要让人们注册我的网站并检索一些信息

database android sync

7
推荐指数
1
解决办法
5万
查看次数

在startActivity(newIntent)之后在onResume()中获取旧的intent intent

在调用活动中,我有以下代码:

Intent intent = new Intent();
intent.setClass(CallingActivity.this, CalledActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(key, new_value);
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)

在调用startActivity(intent)之后,控件转到CalledActivity的onResume().

但是,在CalledActivity的onResume()中,getIntent()为我提供了旧的意图,而不是CallingActivity设置的新意图.

如何在CalledActivity的onResume()中获得新的意图?

android

7
推荐指数
1
解决办法
3362
查看次数

图像没有裁剪

我正在设置一个像这样的background图像LinearLayout:

1.back_xml:

<?xml version="1.0" encoding="UTF-8"?>
  <layer-list xmlns:android="http://schemas.android.com/apk/res/android">  
       <item android:drawable="@drawable/back" >
        </item>
    <item>
        <shape>
            <solid/>
            <stroke android:width="1dip" android:color="#225786" />
            <corners android:radius="10dip"/>
            <padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
        </shape>
    </item> 
Run Code Online (Sandbox Code Playgroud)

2. tile.xml

    <bitmap xmlns:android="http://schemas.android.com/apk/res/android"
        android:src="@drawable/pie_chart_background"
        android:tileMode="repeat">
    </bitmap>
Run Code Online (Sandbox Code Playgroud)

我现在设置back.xml作为一个backgroundLinearLayout它工作正常.

我需要有一个image圆角的边角以及它的边框.但我只有圆角的边框而不是图像我的代码中有什么问题我错过了什么?

这是我的图像的样子:

在此输入图像描述

android image crop bitmap

7
推荐指数
1
解决办法
1693
查看次数

滚动X轴绘图区域 - Silverlight柱系列

我有一个柱系列图表,工作正常.

我有一个功能,我需要添加,我希望horizo​​ntall滚动启用到x轴的绘图区域.

这是屏幕截图:

在此输入图像描述

如果你看到屏幕截图我有六个项目,并且由于更多的项目,条形图非常薄,所以假设我有20个项目,那么条形图将根本不可见.

那么我们可以使X轴条水平滚动吗?

编辑

ResourceDictionary.xaml

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:convertor="clr-namespace:ChartingDV.Provider"
    xmlns:datavis="clr-namespace:System.Windows.Controls.DataVisualization;assembly=System.Windows.Controls.DataVisualization.Toolkit"
    xmlns:charting="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
    xmlns:chartingprimitives="clr-namespace:System.Windows.Controls.DataVisualization.Charting.Primitives;assembly=System.Windows.Controls.DataVisualization.Toolkit">

    <ControlTemplate x:Key="PhoneChartPortraitTemplate" TargetType="charting:Chart">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <datavis:Title
                Content="{TemplateBinding Title}"
                Style="{TemplateBinding TitleStyle}"/>
            <datavis:Legend x:Name="Legend"
                Grid.Row="2"
                Header="{TemplateBinding LegendTitle}"
                Style="{TemplateBinding LegendStyle}">
                <datavis:Legend.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel Orientation="Horizontal"/>
                    </ItemsPanelTemplate>
                </datavis:Legend.ItemsPanel>
                <datavis:Legend.Template>
                    <ControlTemplate TargetType="datavis:Legend">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition />
                            </Grid.RowDefinitions>
                            <ScrollViewer
                                    Grid.Row="1"
                                    HorizontalScrollBarVisibility="Auto"
                                    VerticalScrollBarVisibility="Disabled"
                                    BorderThickness="0"
                                    Padding="0"
                                    IsTabStop="False">
                                <ItemsPresenter
                                        x:Name="Items"
                                        Margin="10,0,10,10"/>
                            </ScrollViewer>
                        </Grid>
                    </ControlTemplate>
                </datavis:Legend.Template>
            </datavis:Legend>
            <chartingprimitives:EdgePanel
                Grid.Column="0"
                Grid.Row="1"
                x:Name="ChartArea"
                Style="{TemplateBinding ChartAreaStyle}">
                <Grid
                    Canvas.ZIndex="-1"
                    Style="{TemplateBinding PlotAreaStyle}" …
Run Code Online (Sandbox Code Playgroud)

c# silverlight wpf charts windows-phone

7
推荐指数
1
解决办法
875
查看次数

无法跨库项目使用 .aidl 文件吗?

本着重用代码的精神,我正在尝试创建一些库项目。但是,我似乎在定义跨库的 .aidl 文件时遇到了问题。问题是这样的:

AI 库中有 Foo.java 和 Foo.aidl。Foo.java 是 Parcelable 所以 aidl 声明是:

Foo.aidl:

package com.example.library.A;
parcelable Foo;
Run Code Online (Sandbox Code Playgroud)

现在我正在尝试创建库 B。在库 BI 中想要定义一个使用类 Foo 的服务接口:

IMyService.aidl:

package com.example.library.B;
import com.example.library.A.Foo;

interface IMyService {
    void requestSomething(in Foo fooBug);
}
Run Code Online (Sandbox Code Playgroud)

该文件无法编译,并抱怨找不到 Foo 的导入。我尝试过引用库 A,并且尝试将库项目添加为外部 jar,但都不起作用。

是否存在我不知道的限制?我的项目设置有问题吗?

我可能应该提到,我已经在项目中直接使用了库 A,没有任何问题,所以我确信库 A 不是问题。

android aidl

6
推荐指数
1
解决办法
3209
查看次数

为布局滑入和滑出动画

我有一个LinearLayout, I am dynamically adding TextView, ImageView to that LinearLayout,现在我已经将OnClickListener添加到这些TextViews和ImageViews.

我有一个arraylist,其中有10个项目,使用for循环我得到每个值并显示,因为它是测验应用程序我有下一个和前一个按钮,当我点击我从arraylist一个接一个地显示项目.Now I need slide In and slide Out animation to apply to this Linear Layout.

我看到了这个:

链接1

链接2

我也尝试过这个

slideIn = new TranslateAnimation(
    TranslateAnimation.RELATIVE_TO_PARENT, 1.0f,
    TranslateAnimation.RELATIVE_TO_PARENT, 0.0f,
    TranslateAnimation.RELATIVE_TO_PARENT, 0.0f,
    TranslateAnimation.RELATIVE_TO_PARENT, 0.0f);

slideIn.setDuration(500);
slideOut = new TranslateAnimation(
    TranslateAnimation.RELATIVE_TO_PARENT, 0.0f,
    TranslateAnimation.RELATIVE_TO_PARENT, -1.0f,
    TranslateAnimation.RELATIVE_TO_PARENT, 0.0f,
    TranslateAnimation.RELATIVE_TO_PARENT, 0.0f);

slideOut.setDuration(500);
Run Code Online (Sandbox Code Playgroud)

但是没有工作,请帮助.

编辑:

问题:我已将此应用于线性布局但发生的情况是,当我点击下一个按钮时,当前问题将向左滑动并显示一个空白屏幕然后它将滑入并显示下一个问题,但我希望一旦当前问题滑动接下来应该是下一个问题.

java android slide

6
推荐指数
1
解决办法
9741
查看次数

获取包含字体大小的文本高度并设置该高度

我有一个Hello现在称为文本的文本我需要在文本大小增加的文本中应用字体后立即对此说12或18应用fontsize.

所以现在我需要使用paint获取文本高度,包括字体大小.

我尝试过以下涂料:

String finalVal ="Hello";

Paint paint = new Paint();
paint.setTextSize(18);
paint.setTypeface(Typeface.SANS_SERIF);
paint.setColor(Color.BLACK);
paint.setStyle(Paint.Style.FILL);

Rect result = new Rect();
// Measure the text rectangle to get the height
paint.getTextBounds(finalVal, 0, finalVal.length(), result);
Run Code Online (Sandbox Code Playgroud)

但它不起作用,请帮忙

编辑

我试图根据textheight动态设置webview的高度我得到单行的文本高度,"Hello"但如果文本中有两行"My name is abc and my dads name is xyz and my moms name is 123" now its not getting the proper text height".

android paint android-webview

6
推荐指数
1
解决办法
1万
查看次数

在linearlayout中水平对齐按钮并使用相等的间距

我试图制作一个线性布局,水平放置5个按钮,间距相等,但所有按钮的大小(宽度)应仅为40dp.

我试过这个:

<LinearLayout   android:id="@+id/button_layout"
                    android:background="#DCE1DC"
                    android:orientation="horizontal"
                    android:weightSum="5"
                    android:layout_width="fill_parent"
                    android:layout_height="70dip">

        <Button     android:id="@+id/button_A"
                    android:layout_weight="1"
                    android:layout_height="60dp"
                    android:layout_width="0dp"
                    android:layout_gravity="center_vertical"
                    android:layout_marginLeft="30dp"/>

        <Button     android:id="@+id/button_B"
                    android:layout_weight="1"
                    android:layout_height="60dp"
                    android:layout_width="0dp"
                    android:layout_gravity="center_vertical"
                    android:layout_marginLeft="30dp"/>

        <Button     android:id="@+id/button_C"
                    android:layout_weight="1"
                    android:layout_height="60dp"
                    android:layout_width="0dp"
                    android:layout_gravity="center_vertical"
                    android:layout_marginLeft="30dp"/>

        <Button     android:id="@+id/button_D"
                    android:layout_weight="1"
                    android:layout_height="60dp"
                    android:layout_width="0dp"
                    android:layout_gravity="center_vertical"
                    android:layout_marginLeft="30dp"/>

        <Button     android:id="@+id/button_E"
                    android:layout_weight="1"
                    android:layout_height="60dp"
                    android:layout_width="0dp"
                    android:layout_gravity="center_vertical"
                    android:layout_marginRight="30dp"
                    android:layout_marginLeft="30dp"/>

    </LinearLayout>
Run Code Online (Sandbox Code Playgroud)

它的工作,但我需要按钮宽度更小,如何实现这一点?

android android-linearlayout

5
推荐指数
1
解决办法
8181
查看次数