我写了一个自定义相机活动来处理我在调用意图图像捕获时遇到的某些问题.用户可以选择保存图像,也可以只使用从中返回的数据OnPictureTakenCallback.
我遇到的问题是正确显示图像的方向.我强制通过调用以纵向显示活动SetRequestedOrientation.
当用户拍照时,我怎么知道相机所处的正确方向?即用户可以以90°(肖像)的旋转拍摄照片.
我试图使用getRotation()窗口管理器的默认显示,但是将请求的方向设置为仅返回的纵向Surface.ROTATION_0.
更新:为了澄清我的另一个问题,byte[]如果用户不保存图像,如何仅从图片回调中的数据确定方向?
更新:使用此代码尝试下面的答案后,我得到的是ExifInterface.ORIENTATION_NORMAL.我还改变了我的代码,只保存从相机返回的文件,因为我不确定有一种简单的方法来确定方向,只需要有byte[]数据.
private PictureCallback mPicture = new PictureCallback()
{
@Override
public void onPictureTaken(byte[] data, Camera camera)
{
File directory = new File(android.os.Environment.getExternalStoragePublicDirectory(android.os.Environment.DIRECTORY_PICTURES),
"MyApp");
if(!directory.exists())
{
if(!directory.mkdirs())
{
Log.d("CAMERA", "Unable to create directory to save photos.");
return;
}
}
File file = new File(directory.getPath() + file.separator + "IMG_" + SimpleDateFormat.getDateTimeInstance().toString() + ".jpg");
FileOutputStream fos = new FileOutputStream(file);
fos.write(data);
fos.close();
ExifInterface exif = new ExifInterface(file.getCanonicalPath());
int …Run Code Online (Sandbox Code Playgroud) 我正在使用Xamarin.Forms,目前正试图制作一个TableView没有节头.现在iOS这看起来很好,因为节标题不可见或可点击,但Android标题上是空白,可见和可点击的.
我试过这个http://forums.xamarin.com/discussion/18037/tablesection-w-out-header
xaml中的代码 -
<TableView>
<TableView.Root>
<TableSection>
<TextCell Text="Login" Command="{Binding Login}" />
<TextCell Text="Sign Up" Command="{Binding SignUp}" />
<TextCell Text="About" Command="{Binding About}"/>
</TableSection>
</TableView.Root>
</TableView>
Run Code Online (Sandbox Code Playgroud)
c#中的代码
Content = new TableView
{
Root = new TableRoot
{
new TableSection ()
{
new TextCell { Text="Login", Command = Login },
new TextCell { Text="Sign Up", Command = SignUp },
new TextCell { Text="About", Command = About },
},
},
};
Run Code Online (Sandbox Code Playgroud) 有没有人试图为Facebook sdk的第3版创建一个新的monodroid绑定?我一直在使用Monodroid Facebook Binding创建的旧版Facebook sdk .但新的Facebook sdk几乎所有这些方法都被弃用了.
我在设置新绑定时遇到了麻烦,基本上这个com.facebook.android.Facebook类现在已被弃用,并且Facebook.Authorize被替换为Session.我可以创建一个新的facebook sdk的jar文件,但是Session在查看.dll时,该类没有出现在visual studio的对象浏览器中.的Session类是公共和器械java.io.Serializable,其包括在Mono.Android参考.任何帮助或建议将不胜感激.
编辑:用这个乱了几天之后,我能够通过解决这个问题来解决我的问题,删除节点Metadata.xml.
<remove-node path="/api/package[@name='com.facebook']/class[@name='Session.OpenRequest']/method[@name='setPermissions']"/>
Run Code Online (Sandbox Code Playgroud)
这带来了其他问题,可以通过添加更多<attr>标签来解决.
<remove-node path="/api/package[@name='com.facebook.model']/class[@name='PropertyName']"/>
<attr path="/api/package[@name='com.facebook.widget']/class[@name='GraphObjectAdapter']" name="visibility">public</attr>
<attr path="/api/package[@name='com.facebook.widget']/class[@name='GraphObjectPagingLoader']" name="visibility">public</attr>
<attr path="/api/package[@name='com.facebook.widget']/class[@name='FacebookFragment']" name="visibility">public</attr>
<attr path="/api/package[@name='com.facebook.widget']/class[@name='SimpleGraphObjectCursor']" name="visibility">public</attr>
<attr path="/api/package[@name='com.facebook.widget']/interface[@name='GraphObjectCursor']" name="visibility">public</attr>
Run Code Online (Sandbox Code Playgroud)
在构建这个尝试后,我得到了一个点,我在GraphObject.SectionAndItem课堂上遇到了多个错误.
Error 41 Argument 1: cannot convert from 'Com.Facebook.Widget.GraphObjectAdapter.SectionAndItem.Type' to 'System.IntPtr' E:\Android\FacebookBinding\FacebookBinding\FacebookBinding\obj\Debug\generated\src\Com.Facebook.Widget.GraphObjectAdapter.cs 345 64 FacebookBinding
Error 39 Operator '!=' cannot be applied to operands of type 'Com.Facebook.Widget.GraphObjectAdapter.SectionAndItem.Type' …Run Code Online (Sandbox Code Playgroud) 我有一个ListView选择器设置只有一个纯色.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:id="@+id/assignmentSelectedItem" />
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/assignmentsListView"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:listSelector="@drawable/assignment_list_selector" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
assignment_list_selector.xml -
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@android:color/white" />
<item android:drawable="@android:color/transparent"/>
</selector>
Run Code Online (Sandbox Code Playgroud)
在ListView.Adapter我的列表中,我有将其视图背景设置为特定颜色的项目.我的问题是,为什么选择器在我的列表视图中显示所选颜色时根本不起作用?如果是这样,任何建议让我仍然设置视图的背景颜色.